add field profile and profile-employee search-personal
This commit is contained in:
parent
bda7c1328f
commit
eea123fbad
2 changed files with 348 additions and 86 deletions
|
|
@ -77,7 +77,7 @@ export class ProfileController extends Controller {
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true },
|
where: { orgRevisionIsCurrent: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalary",
|
"profileSalary",
|
||||||
|
|
@ -87,16 +87,20 @@ export class ProfileController extends Controller {
|
||||||
"current_holders.orgChild1",
|
"current_holders.orgChild1",
|
||||||
"current_holders.orgChild2",
|
"current_holders.orgChild2",
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4"
|
"current_holders.orgChild4",
|
||||||
],
|
],
|
||||||
where: { id: id, },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId })
|
const province = await this.provinceRepository.findOneBy({
|
||||||
const district = await this.districtRepository.findOneBy({ id: profile.registrationDistrictId })
|
id: profile.registrationProvinceId,
|
||||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId })
|
});
|
||||||
|
const district = await this.districtRepository.findOneBy({
|
||||||
|
id: profile.registrationDistrictId,
|
||||||
|
});
|
||||||
|
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId });
|
||||||
|
|
||||||
const root =
|
const root =
|
||||||
profile.current_holders == null ||
|
profile.current_holders == null ||
|
||||||
profile.current_holders.length == 0 ||
|
profile.current_holders.length == 0 ||
|
||||||
|
|
@ -147,22 +151,18 @@ export class ProfileController extends Controller {
|
||||||
DateOfBirth: profile.birthDate,
|
DateOfBirth: profile.birthDate,
|
||||||
DateRetire: profile.dateRetire,
|
DateRetire: profile.dateRetire,
|
||||||
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
||||||
SalaryAmount: profile.profileSalary.length > 0
|
SalaryAmount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||||
? profile.profileSalary[0].amount
|
Education:
|
||||||
: null,
|
profile.profileEducations.length > 0
|
||||||
Education: profile.profileEducations.length > 0
|
? profile.profileEducations[profile.profileEducations.length - 1].institute
|
||||||
? profile.profileEducations[profile.profileEducations.length-1].institute
|
: null,
|
||||||
: null,
|
|
||||||
AppointText: profile.dateAppoint,
|
AppointText: profile.dateAppoint,
|
||||||
SalaryDate: profile.profileSalary.length > 0
|
SalaryDate: profile.profileSalary.length > 0 ? profile.profileSalary[0].date : null,
|
||||||
? profile.profileSalary[0].date
|
|
||||||
: null,
|
|
||||||
PositionName: profile.position,
|
PositionName: profile.position,
|
||||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
}
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -945,7 +945,7 @@ export class ProfileController extends Controller {
|
||||||
"profile.citizenId",
|
"profile.citizenId",
|
||||||
"profileSalary.position",
|
"profileSalary.position",
|
||||||
"profileSalary.posNo",
|
"profileSalary.posNo",
|
||||||
"profileSalary.date"
|
"profileSalary.date",
|
||||||
])
|
])
|
||||||
.andWhere(
|
.andWhere(
|
||||||
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
|
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
|
||||||
|
|
@ -965,27 +965,27 @@ export class ProfileController extends Controller {
|
||||||
)
|
)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const mapData = profiles.map(profile => {
|
const mapData = profiles.map((profile) => {
|
||||||
let profileSalary;
|
let profileSalary;
|
||||||
if (profile.profileSalary && profile.profileSalary.length > 0) {
|
if (profile.profileSalary && profile.profileSalary.length > 0) {
|
||||||
profileSalary = profile.profileSalary.reduce((latest, current) => {
|
profileSalary = profile.profileSalary.reduce((latest, current) => {
|
||||||
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: profile.id,
|
id: profile.id,
|
||||||
// prefix: profile.prefix,
|
// prefix: profile.prefix,
|
||||||
// firstName: profile.firstName,
|
// firstName: profile.firstName,
|
||||||
// lastName: profile.lastName,
|
// lastName: profile.lastName,
|
||||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
position: profileSalary ? profileSalary.position : null,
|
position: profileSalary ? profileSalary.position : null,
|
||||||
posNo: profileSalary ? profileSalary.posNo : null,
|
posNo: profileSalary ? profileSalary.posNo : null,
|
||||||
date: profileSalary ? profileSalary.date : null
|
date: profileSalary ? profileSalary.date : null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1496,33 +1496,141 @@ export class ProfileController extends Controller {
|
||||||
case "idcard":
|
case "idcard":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { citizenId: Like(`%${body.keyword}%`) },
|
where: { citizenId: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalary",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "firstname":
|
case "firstname":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { firstName: Like(`%${body.keyword}%`) },
|
where: { firstName: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalary",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lastname":
|
case "lastname":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { lastName: Like(`%${body.keyword}%`) },
|
where: { lastName: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalary",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalary",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
|
||||||
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 shortName =
|
||||||
|
item.current_holders.length == 0
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||||
|
null
|
||||||
|
? `${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)?.orgChild3 !=
|
||||||
|
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) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
|
?.orgChild2 != 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) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
|
?.orgChild1 != 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) !=
|
||||||
|
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 =
|
||||||
|
item.current_holders.length == 0 ||
|
||||||
|
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
|
||||||
|
let salary: any = "";
|
||||||
|
if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
|
||||||
|
let _salary: any = item.profileSalary.sort(
|
||||||
|
(a, b) =>
|
||||||
|
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
|
||||||
|
);
|
||||||
|
if (_salary.length > 0) {
|
||||||
|
salary = _salary[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootHolder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgRoot;
|
||||||
|
const child1Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild1;
|
||||||
|
const child2Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild2;
|
||||||
|
const child3Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild3;
|
||||||
|
const child4Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild4;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
prefix: item.prefix,
|
prefix: item.prefix,
|
||||||
|
|
@ -1533,6 +1641,29 @@ export class ProfileController extends Controller {
|
||||||
idcard: item.citizenId,
|
idcard: item.citizenId,
|
||||||
email: item.email,
|
email: item.email,
|
||||||
phone: item.phone,
|
phone: item.phone,
|
||||||
|
name: fullName,
|
||||||
|
positionLevel: item.posLevelId,
|
||||||
|
positionLevelName: item.posLevel?.posLevelName,
|
||||||
|
positionType: item.posTypeId,
|
||||||
|
positionTypeName: item.posType?.posTypeName,
|
||||||
|
posNo: shortName,
|
||||||
|
organization: root == null ? null : root.orgRootShortName,
|
||||||
|
salary: salary == "" ? "" : salary.amount,
|
||||||
|
root: rootHolder?.orgRootName ?? null,
|
||||||
|
rootId: rootHolder?.id ?? null,
|
||||||
|
rootShortName: rootHolder?.orgRootShortName ?? null,
|
||||||
|
child1: child1Holder?.orgChild1Name ?? null,
|
||||||
|
child1Id: child1Holder?.id ?? null,
|
||||||
|
child1ShortName: child1Holder?.orgChild1ShortName ?? null,
|
||||||
|
child2: child2Holder?.orgChild2Name ?? null,
|
||||||
|
child2Id: child2Holder?.id ?? null,
|
||||||
|
child2ShortName: child2Holder?.orgChild2ShortName ?? null,
|
||||||
|
child3: child3Holder?.orgChild3Name ?? null,
|
||||||
|
child3Id: child3Holder?.id ?? null,
|
||||||
|
child3ShortName: child3Holder?.orgChild3ShortName ?? null,
|
||||||
|
child4: child4Holder?.orgChild4Name ?? null,
|
||||||
|
child4Id: child4Holder?.id ?? null,
|
||||||
|
child4ShortName: child4Holder?.orgChild4ShortName ?? null,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true },
|
where: { orgRevisionIsCurrent: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalarys",
|
"profileSalarys",
|
||||||
|
|
@ -77,16 +77,20 @@ export class ProfileEmployeeController extends Controller {
|
||||||
"current_holders.orgChild1",
|
"current_holders.orgChild1",
|
||||||
"current_holders.orgChild2",
|
"current_holders.orgChild2",
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4"
|
"current_holders.orgChild4",
|
||||||
],
|
],
|
||||||
where: { id: id, },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId })
|
const province = await this.provinceRepository.findOneBy({
|
||||||
const district = await this.districtRepository.findOneBy({ id: profile.registrationDistrictId })
|
id: profile.registrationProvinceId,
|
||||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId })
|
});
|
||||||
|
const district = await this.districtRepository.findOneBy({
|
||||||
|
id: profile.registrationDistrictId,
|
||||||
|
});
|
||||||
|
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId });
|
||||||
|
|
||||||
const root =
|
const root =
|
||||||
profile.current_holders == null ||
|
profile.current_holders == null ||
|
||||||
profile.current_holders.length == 0 ||
|
profile.current_holders.length == 0 ||
|
||||||
|
|
@ -137,22 +141,18 @@ export class ProfileEmployeeController extends Controller {
|
||||||
DateOfBirth: profile.birthDate,
|
DateOfBirth: profile.birthDate,
|
||||||
DateRetire: profile.dateRetire,
|
DateRetire: profile.dateRetire,
|
||||||
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
||||||
SalaryAmount: profile.profileSalarys.length > 0
|
SalaryAmount: profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
|
||||||
? profile.profileSalarys[0].amount
|
Education:
|
||||||
: null,
|
profile.profileEducations.length > 0
|
||||||
Education: profile.profileEducations.length > 0
|
? profile.profileEducations[profile.profileEducations.length - 1].institute
|
||||||
? profile.profileEducations[profile.profileEducations.length-1].institute
|
: null,
|
||||||
: null,
|
|
||||||
AppointText: profile.dateAppoint,
|
AppointText: profile.dateAppoint,
|
||||||
SalaryDate: profile.profileSalarys.length > 0
|
SalaryDate: profile.profileSalarys.length > 0 ? profile.profileSalarys[0].date : null,
|
||||||
? profile.profileSalarys[0].date
|
|
||||||
: null,
|
|
||||||
PositionName: profile.position,
|
PositionName: profile.position,
|
||||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
}
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -658,7 +658,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
"profileEmployee.citizenId",
|
"profileEmployee.citizenId",
|
||||||
"profileSalarys.position",
|
"profileSalarys.position",
|
||||||
"profileSalarys.posNo",
|
"profileSalarys.posNo",
|
||||||
"profileSalarys.date"
|
"profileSalarys.date",
|
||||||
])
|
])
|
||||||
.andWhere(
|
.andWhere(
|
||||||
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
|
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
|
||||||
|
|
@ -678,24 +678,24 @@ export class ProfileEmployeeController extends Controller {
|
||||||
)
|
)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
const mapData = profiles.map(profile => {
|
const mapData = profiles.map((profile) => {
|
||||||
let profileSalary;
|
let profileSalary;
|
||||||
if (profile.profileSalarys && profile.profileSalarys.length > 0) {
|
if (profile.profileSalarys && profile.profileSalarys.length > 0) {
|
||||||
profileSalary = profile.profileSalarys.reduce((latest, current) => {
|
profileSalary = profile.profileSalarys.reduce((latest, current) => {
|
||||||
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: profile.id,
|
id: profile.id,
|
||||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
position: profileSalary ? profileSalary.position : null,
|
position: profileSalary ? profileSalary.position : null,
|
||||||
posNo: profileSalary ? profileSalary.posNo : null,
|
posNo: profileSalary ? profileSalary.posNo : null,
|
||||||
date: profileSalary ? profileSalary.date : null
|
date: profileSalary ? profileSalary.date : null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -830,43 +830,174 @@ export class ProfileEmployeeController extends Controller {
|
||||||
case "idcard":
|
case "idcard":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { citizenId: Like(`%${body.keyword}%`) },
|
where: { citizenId: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalary",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "firstname":
|
case "firstname":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { firstName: Like(`%${body.keyword}%`) },
|
where: { firstName: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalarys",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lastname":
|
case "lastname":
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
where: { lastName: Like(`%${body.keyword}%`) },
|
where: { lastName: Like(`%${body.keyword}%`) },
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalarys",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
findProfile = await this.profileRepo.find({
|
findProfile = await this.profileRepo.find({
|
||||||
relations: ["posType", "posLevel"],
|
relations: [
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"profileSalarys",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"current_holders.orgChild1",
|
||||||
|
"current_holders.orgChild2",
|
||||||
|
"current_holders.orgChild3",
|
||||||
|
"current_holders.orgChild4",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
|
||||||
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 shortName =
|
||||||
|
item.current_holders.length == 0
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||||
|
null
|
||||||
|
? `${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)?.orgChild3 !=
|
||||||
|
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) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
|
?.orgChild2 != 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) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
|
?.orgChild1 != 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) !=
|
||||||
|
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 =
|
||||||
|
item.current_holders.length == 0 ||
|
||||||
|
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
|
||||||
|
let salary: any = "";
|
||||||
|
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) {
|
||||||
|
let _salary: any = item.profileSalarys.sort(
|
||||||
|
(a, b) =>
|
||||||
|
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
|
||||||
|
);
|
||||||
|
if (_salary.length > 0) {
|
||||||
|
salary = _salary[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootHolder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgRoot;
|
||||||
|
const child1Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild1;
|
||||||
|
const child2Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild2;
|
||||||
|
const child3Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild3;
|
||||||
|
const child4Holder = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.orgChild4;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
rank: item.rank,
|
|
||||||
prefix: item.prefix,
|
prefix: item.prefix,
|
||||||
|
rank: item.rank,
|
||||||
firstName: item.firstName,
|
firstName: item.firstName,
|
||||||
lastName: item.lastName,
|
lastName: item.lastName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
idcard: item.citizenId,
|
idcard: item.citizenId,
|
||||||
email: item.email,
|
email: item.email,
|
||||||
phone: item.phone,
|
phone: item.phone,
|
||||||
|
name: fullName,
|
||||||
|
positionLevel: item.posLevelId,
|
||||||
|
positionLevelName: item.posLevel?.posLevelName,
|
||||||
|
positionType: item.posTypeId,
|
||||||
|
positionTypeName: item.posType?.posTypeName,
|
||||||
|
posNo: shortName,
|
||||||
|
organization: root == null ? null : root.orgRootShortName,
|
||||||
|
salary: salary == "" ? "" : salary.amount,
|
||||||
|
root: rootHolder?.orgRootName ?? null,
|
||||||
|
rootId: rootHolder?.id ?? null,
|
||||||
|
rootShortName: rootHolder?.orgRootShortName ?? null,
|
||||||
|
child1: child1Holder?.orgChild1Name ?? null,
|
||||||
|
child1Id: child1Holder?.id ?? null,
|
||||||
|
child1ShortName: child1Holder?.orgChild1ShortName ?? null,
|
||||||
|
child2: child2Holder?.orgChild2Name ?? null,
|
||||||
|
child2Id: child2Holder?.id ?? null,
|
||||||
|
child2ShortName: child2Holder?.orgChild2ShortName ?? null,
|
||||||
|
child3: child3Holder?.orgChild3Name ?? null,
|
||||||
|
child3Id: child3Holder?.id ?? null,
|
||||||
|
child3ShortName: child3Holder?.orgChild3ShortName ?? null,
|
||||||
|
child4: child4Holder?.orgChild4Name ?? null,
|
||||||
|
child4Id: child4Holder?.id ?? null,
|
||||||
|
child4ShortName: child4Holder?.orgChild4ShortName ?? null,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue