เพิ่มเวลาลูกจ้าง

This commit is contained in:
kittapath 2024-11-07 15:55:23 +07:00
parent b1c365a4da
commit 2c1e1dd8ff
9 changed files with 390 additions and 244 deletions

View file

@ -252,7 +252,6 @@ export class ImportDataController extends Controller {
@Post("uploadProfileSalary-Officer") @Post("uploadProfileSalary-Officer")
async UploadFileSQLSalary(@Request() request: { user: Record<string, any> }) { async UploadFileSQLSalary(@Request() request: { user: Record<string, any> }) {
let rowCount = 0; let rowCount = 0;
let profileSalarys: any = [];
let null_: any = null; let null_: any = null;
const [profiles, total] = await AppDataSource.getRepository(Profile) const [profiles, total] = await AppDataSource.getRepository(Profile)
@ -291,7 +290,6 @@ export class ImportDataController extends Controller {
], ],
}); });
// profileSalarys = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
rowCount++; rowCount++;
@ -322,21 +320,12 @@ export class ImportDataController extends Controller {
profileSalary.lastUpdateFullName = request.user.name; profileSalary.lastUpdateFullName = request.user.name;
profileSalary.createdAt = new Date(); profileSalary.createdAt = new Date();
profileSalary.lastUpdatedAt = new Date(); profileSalary.lastUpdatedAt = new Date();
// profileSalarys.push(profileSalary);
// await this.salaryRepository.save(profileSalary);
// if (profileSalarys.length === BATCH_SIZE) {
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.salaryRepository.save(profileSalary); await this.salaryRepository.save(profileSalary);
// profileSalarys = await [];
// }
}), }),
); );
// await this.salaryRepository.save(profileSalarys);
// profileSalarys = await [];
}), }),
); );
// await this.salaryRepository.save(profileSalarys);
// }
console.log(rowCount); console.log(rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -347,7 +336,6 @@ export class ImportDataController extends Controller {
@Post("uploadProfileSalary-Employee") @Post("uploadProfileSalary-Employee")
async UploadFileSQLSalaryEmp(@Request() request: { user: Record<string, any> }) { async UploadFileSQLSalaryEmp(@Request() request: { user: Record<string, any> }) {
let rowCount = 0; let rowCount = 0;
let profileSalarys: any = [];
let null_: any = null; let null_: any = null;
const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
@ -386,7 +374,6 @@ export class ImportDataController extends Controller {
], ],
}); });
profileSalarys = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
rowCount++; rowCount++;
@ -417,21 +404,13 @@ export class ImportDataController extends Controller {
profileSalary.lastUpdateFullName = request.user.name; profileSalary.lastUpdateFullName = request.user.name;
profileSalary.createdAt = new Date(); profileSalary.createdAt = new Date();
profileSalary.lastUpdatedAt = new Date(); profileSalary.lastUpdatedAt = new Date();
// profileSalarys.push(profileSalary);
// await this.salaryRepository.save(profileSalary);
// if (profileSalarys.length === BATCH_SIZE) {
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.salaryRepository.save(profileSalary); await this.salaryRepository.save(profileSalary);
// profileSalarys = await [];
// }
}), }),
); );
// await this.salaryRepository.save(profileSalarys);
// profileSalarys = await [];
}), }),
); );
// } // }
// await this.salaryRepository.save(profileSalarys);
console.log(rowCount); console.log(rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -102,14 +102,14 @@ export class OrganizationDotnetController extends Controller {
.createQueryBuilder("profile") .createQueryBuilder("profile")
.leftJoinAndSelect("profile.posLevel", "posLevel") .leftJoinAndSelect("profile.posLevel", "posLevel")
.leftJoinAndSelect("profile.posType", "posType") .leftJoinAndSelect("profile.posType", "posType")
.leftJoinAndSelect("profile.profileSalarys", "profileSalarys") .leftJoinAndSelect("profile.profileSalary", "profileSalary")
.leftJoinAndSelect("profile.current_holders", "current_holders") .leftJoinAndSelect("profile.current_holders", "current_holders")
.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")
.orderBy("profileSalarys.order", "DESC"); .orderBy("profileSalary.order", "DESC");
if (body.citizenId || body.firstName || body.lastName) { if (body.citizenId || body.firstName || body.lastName) {
queryBuilder.where( queryBuilder.where(
@ -285,7 +285,76 @@ export class OrganizationDotnetController extends Controller {
}, },
}, },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) {
const profile = await this.profileEmpRepo.findOne({
relations: {
posLevel: true,
posType: true,
profileSalary: true,
profileInsignias: true,
},
where: { keycloak: keycloakId },
order: {
profileSalary: {
date: "DESC",
},
profileInsignias: {
receiveDate: "DESC",
},
},
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const mapProfile = {
id: profile.id,
avatar: profile.avatar,
avatarName: profile.avatarName,
rank: profile.rank,
prefix: profile.prefix,
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,
position: profile.position,
posLevelId: profile.posLevelId,
email: profile.email,
phone: profile.phone,
keycloak: profile.keycloak,
isProbation: profile.isProbation,
isLeave: profile.isLeave,
leaveReason: profile.leaveReason,
dateRetire: profile.dateRetire,
dateAppoint: profile.dateAppoint,
dateRetireLaw: profile.dateRetireLaw,
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate,
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
gender: profile.gender,
relationship: profile.relationship,
religion: profile.religion,
bloodGroup: profile.bloodGroup,
registrationAddress: profile.registrationAddress,
registrationProvinceId: profile.registrationProvinceId,
registrationDistrictId: profile.registrationDistrictId,
registrationSubDistrictId: profile.registrationSubDistrictId,
registrationZipCode: profile.registrationZipCode,
currentAddress: profile.currentAddress,
currentProvinceId: profile.currentProvinceId,
currentSubDistrictId: profile.currentSubDistrictId,
currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null,
};
return new HttpSuccess(mapProfile);
}
const mapProfile = { const mapProfile = {
id: profile.id, id: profile.id,
@ -446,12 +515,12 @@ export class OrganizationDotnetController extends Controller {
relations: { relations: {
posLevel: true, posLevel: true,
posType: true, posType: true,
profileSalarys: true, profileSalary: true,
profileInsignias: true, profileInsignias: true,
}, },
where: { citizenId: citizenId }, where: { citizenId: citizenId },
order: { order: {
profileSalarys: { profileSalary: {
date: "DESC", date: "DESC",
}, },
profileInsignias: { profileInsignias: {
@ -505,7 +574,7 @@ export class OrganizationDotnetController extends Controller {
dutyTimeEffectiveDate: null, dutyTimeEffectiveDate: null,
posLevel: _profile.posLevel ? _profile.posLevel : null, posLevel: _profile.posLevel ? _profile.posLevel : null,
posType: _profile.posType ? _profile.posType : null, posType: _profile.posType ? _profile.posType : null,
profileSalary: _profile.profileSalarys, profileSalary: _profile.profileSalary,
profileInsignia: _profile.profileInsignias, profileInsignia: _profile.profileInsignias,
profileType: "EMPLOYEE", profileType: "EMPLOYEE",
}; };
@ -656,12 +725,12 @@ export class OrganizationDotnetController extends Controller {
relations: { relations: {
posLevel: true, posLevel: true,
posType: true, posType: true,
profileSalarys: true, profileSalary: true,
profileInsignias: true, profileInsignias: true,
}, },
where: { current_holders: { orgRootId: rootId } }, where: { current_holders: { orgRootId: rootId } },
order: { order: {
profileSalarys: { profileSalary: {
date: "DESC", date: "DESC",
}, },
profileInsignias: { profileInsignias: {
@ -715,7 +784,7 @@ export class OrganizationDotnetController extends Controller {
// dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, // dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel ? profile.posLevel : null, posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType ? profile.posType : null, posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalarys, profileSalary: profile.profileSalary,
profileInsignia: profile.profileInsignias, profileInsignia: profile.profileInsignias,
})); }));
@ -1103,7 +1172,20 @@ export class OrganizationDotnetController extends Controller {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: body.profileId }, where: { id: body.profileId },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) {
const profile = await this.profileEmpRepo.findOne({
where: { id: body.profileId },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
Object.assign(profile, body);
profile.dutyTimeId = body.roundId;
profile.dutyTimeEffectiveDate = body.effectiveDate;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date();
await this.profileEmpRepo.save(profile);
return new HttpSuccess();
}
Object.assign(profile, body); Object.assign(profile, body);
profile.dutyTimeId = body.roundId; profile.dutyTimeId = body.roundId;
profile.dutyTimeEffectiveDate = body.effectiveDate; profile.dutyTimeEffectiveDate = body.effectiveDate;

View file

@ -283,7 +283,7 @@ export class OrganizationUnauthorizeController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3") .leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4") .leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions") .leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.profileLeaves", "profileLeaves") .leftJoinAndSelect("current_holder.profileLeaves", "profileLeaves")
.leftJoinAndSelect("current_holder.profileAssessments", "profileAssessments") .leftJoinAndSelect("current_holder.profileAssessments", "profileAssessments")
@ -378,9 +378,9 @@ export class OrganizationUnauthorizeController extends Controller {
} }
const amount = const amount =
item.current_holder == null || item.current_holder.profileSalarys.length == 0 item.current_holder == null || item.current_holder.profileSalary.length == 0
? null ? null
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount; : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );

View file

@ -252,9 +252,8 @@ export class ProfileController extends Controller {
profile.dateRetire != null profile.dateRetire != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire))
: "-", : "-",
salaryAmount: profile.amount != null salaryAmount:
? Extension.ToThaiNumber(profile.amount.toLocaleString()) profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-",
: "-",
registrationAddress: Extension.ToThaiNumber( registrationAddress: Extension.ToThaiNumber(
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
), ),
@ -1911,21 +1910,21 @@ export class ProfileController extends Controller {
// const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) }) // const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) })
// const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) }) // const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) })
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -1935,13 +1934,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
if (profile.isProbation != false) { if (profile.isProbation != false) {
profile.isProbation = false; profile.isProbation = false;
profile.lastUpdateUserId = req.user.sub; profile.lastUpdateUserId = req.user.sub;
@ -1956,12 +1957,12 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
amount: profile.amount, amount: profile.amount,
positionSalaryAmount:profile.positionSalaryAmount, positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount,
order: order:
profile.profileSalary.length >= 0 profile.profileSalary.length >= 0
@ -1999,7 +2000,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2026,21 +2027,21 @@ export class ProfileController extends Controller {
_profile.lastUpdatedAt = new Date(); _profile.lastUpdatedAt = new Date();
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2050,13 +2051,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2065,7 +2068,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2109,7 +2112,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2135,21 +2138,21 @@ export class ProfileController extends Controller {
_profile.lastUpdatedAt = new Date(); _profile.lastUpdatedAt = new Date();
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2159,13 +2162,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2174,7 +2179,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2218,7 +2223,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2244,21 +2249,21 @@ export class ProfileController extends Controller {
_profile.lastUpdatedAt = new Date(); _profile.lastUpdatedAt = new Date();
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2268,13 +2273,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2283,7 +2290,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2343,7 +2350,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2369,21 +2376,21 @@ export class ProfileController extends Controller {
_profile.lastUpdatedAt = new Date(); _profile.lastUpdatedAt = new Date();
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2393,13 +2400,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2408,7 +2417,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2452,7 +2461,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2477,21 +2486,21 @@ export class ProfileController extends Controller {
_profile.lastUpdateFullName = req.user.name; _profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2501,13 +2510,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2516,7 +2527,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2560,7 +2571,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2579,21 +2590,21 @@ export class ProfileController extends Controller {
// profile.lastUpdateFullName = req.user.name; // profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2603,13 +2614,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2618,7 +2631,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2661,7 +2674,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2680,21 +2693,21 @@ export class ProfileController extends Controller {
// profile.lastUpdateFullName = req.user.name; // profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2704,13 +2717,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2719,7 +2734,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2762,7 +2777,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2781,21 +2796,21 @@ export class ProfileController extends Controller {
// profile.lastUpdateFullName = req.user.name; // profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2805,14 +2820,16 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2821,7 +2838,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2864,7 +2881,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2883,21 +2900,21 @@ export class ProfileController extends Controller {
// profile.lastUpdateFullName = req.user.name; // profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -2907,13 +2924,15 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -2922,7 +2941,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -2965,7 +2984,7 @@ export class ProfileController extends Controller {
}, },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: ["profileSalary","posType","posLevel"], relations: ["profileSalary", "posType", "posLevel"],
where: { id: body.profileId }, where: { id: body.profileId },
order: { order: {
profileSalary: { profileSalary: {
@ -2984,21 +3003,21 @@ export class ProfileController extends Controller {
// profile.lastUpdateFullName = req.user.name; // profile.lastUpdateFullName = req.user.name;
const orgRevision = await this.orgRevisionRepo.findOne({ const orgRevision = await this.orgRevisionRepo.findOne({
where:{ where: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false orgRevisionIsDraft: false,
} },
}) });
const shortName = const shortName =
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 !=
null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 !=
?.orgChild3 != null null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
@ -3008,14 +3027,16 @@ export class ProfileController extends Controller {
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
: null; : null;
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; let position =
profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId, profileId: body.profileId,
date: body.date, date: body.date,
@ -3024,7 +3045,7 @@ export class ProfileController extends Controller {
position: profile.position, position: profile.position,
positionType: profile.posType.posTypeName, positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName, positionLevel: profile.posLevel.posLevelName,
posNo: shortName?shortName:"-", posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-", positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-", positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -4413,10 +4434,10 @@ export class ProfileController extends Controller {
"posType", "posType",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
"profileSalarys", "profileSalary",
], ],
order: { order: {
profileSalarys: { profileSalary: {
order: "DESC", order: "DESC",
}, },
}, },
@ -4545,23 +4566,28 @@ export class ProfileController extends Controller {
nodeId: null, nodeId: null,
type: profile.employeeClass, type: profile.employeeClass,
salary: salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null, profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }
@ -4679,24 +4705,29 @@ export class ProfileController extends Controller {
child4ShortName: child4 == null ? null : child4.orgChild4ShortName, child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null, node: null,
nodeId: null, nodeId: null,
salary: profile ? profile.amount: null, salary: profile ? profile.amount : null,
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }
@ -5209,18 +5240,23 @@ export class ProfileController extends Controller {
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }
@ -5424,7 +5460,7 @@ export class ProfileController extends Controller {
posNo: shortName, posNo: shortName,
isPosmasterAct: data.length > 0, isPosmasterAct: data.length > 0,
posmasterAct: data, posmasterAct: data,
salary: profile ? profile.amount: null, salary: profile ? profile.amount : null,
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
@ -5578,7 +5614,7 @@ export class ProfileController extends Controller {
child4ShortName: child4 == null ? null : child4.orgChild4ShortName, child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null, node: null,
nodeId: null, nodeId: null,
amount: profile ? profile.amount : null, amount: profile ? profile.amount : null,
positionSalaryAmount: profile ? profile.positionSalaryAmount : null, positionSalaryAmount: profile ? profile.positionSalaryAmount : null,
mouthSalaryAmount: profile ? profile.mouthSalaryAmount : null, mouthSalaryAmount: profile ? profile.mouthSalaryAmount : null,
}; };
@ -5707,18 +5743,23 @@ export class ProfileController extends Controller {
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }

View file

@ -125,7 +125,7 @@ export class ProfileEmployeeController extends Controller {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: [ relations: [
"profileSalarys", "profileSalary",
"profileEducations", "profileEducations",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
@ -136,7 +136,7 @@ export class ProfileEmployeeController extends Controller {
], ],
where: { id: id }, where: { id: id },
order: { order: {
profileSalarys: { profileSalary: {
date: "DESC", date: "DESC",
}, },
}, },
@ -256,16 +256,16 @@ export class ProfileEmployeeController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire))
: "-", : "-",
salaryAmount: salaryAmount:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString()) ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
: "-", : "-",
registrationAddress: Extension.ToThaiNumber( registrationAddress: Extension.ToThaiNumber(
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
), ),
salaryDate: salaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile.profileSalarys[0].date), Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date),
) )
: "-", : "-",
positionName: profile.position != null ? profile.position : "-", positionName: profile.position != null ? profile.position : "-",
@ -1783,20 +1783,20 @@ export class ProfileEmployeeController extends Controller {
) { ) {
const profiles = await this.profileRepo const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee") .createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.profileSalarys", "profileSalarys") .leftJoinAndSelect("profileEmployee.profileSalary", "profileSalary")
.select([ .select([
"profileEmployee.id", "profileEmployee.id",
"profileEmployee.prefix", "profileEmployee.prefix",
"profileEmployee.firstName", "profileEmployee.firstName",
"profileEmployee.lastName", "profileEmployee.lastName",
"profileEmployee.citizenId", "profileEmployee.citizenId",
"profileSalarys.position", "profileSalary.position",
"profileSalarys.posNo", "profileSalary.posNo",
"profileSalarys.date", "profileSalary.date",
]) ])
.andWhere( .andWhere(
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
? "profileSalarys.position LIKE :position" ? "profileSalary.position LIKE :position"
: "1=2", : "1=2",
{ {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
@ -1804,7 +1804,7 @@ export class ProfileEmployeeController extends Controller {
) )
.orWhere( .orWhere(
requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined
? "profileSalarys.posNo LIKE :posNo" ? "profileSalars.posNo LIKE :posNo"
: "1=2", : "1=2",
{ {
posNo: `%${requestBody.posNo}%`, posNo: `%${requestBody.posNo}%`,
@ -1814,8 +1814,8 @@ export class ProfileEmployeeController extends Controller {
const mapData = profiles.map((profile) => { const mapData = profiles.map((profile) => {
let profileSalary; let profileSalary;
if (profile.profileSalarys && profile.profileSalarys.length > 0) { if (profile.profileSalary && profile.profileSalary.length > 0) {
profileSalary = profile.profileSalarys.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;
}); });
} }
@ -1850,10 +1850,10 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
"profileSalarys", "profileSalary",
], ],
order: { order: {
profileSalarys: { profileSalary: {
order: "DESC", order: "DESC",
}, },
}, },
@ -1976,7 +1976,7 @@ export class ProfileEmployeeController extends Controller {
node: null, node: null,
nodeId: null, nodeId: null,
salary: salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null, profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
}; };
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }
@ -2009,7 +2009,7 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -2028,7 +2028,7 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -2047,7 +2047,7 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -2065,7 +2065,7 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -2122,8 +2122,8 @@ export class ProfileEmployeeController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = ""; let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) { if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalarys.sort( let _salary: any = item.profileSalary.sort(
(a, b) => (a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()), (b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
); );
@ -2779,7 +2779,7 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3") .leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4") .leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions") .leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType") .leftJoinAndSelect("current_holder.posType", "posType")
@ -2877,9 +2877,9 @@ export class ProfileEmployeeController extends Controller {
} }
const amount = const amount =
item.current_holder == null || item.current_holder.profileSalarys.length == 0 item.current_holder == null || item.current_holder.profileSalary.length == 0
? null ? null
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount; : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );
@ -3678,7 +3678,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`), citizenId: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3690,7 +3690,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`), firstName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3702,7 +3702,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`), lastName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3713,7 +3713,7 @@ export class ProfileEmployeeController extends Controller {
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3764,8 +3764,8 @@ export class ProfileEmployeeController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = ""; let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) { if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalarys.sort( let _salary: any = item.profileSalary.sort(
(a, b) => (a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()), (b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
); );
@ -3832,10 +3832,10 @@ export class ProfileEmployeeController extends Controller {
"posType", "posType",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
"profileSalarys", "profileSalary",
], ],
order: { order: {
profileSalarys: { profileSalary: {
order: "DESC", order: "DESC",
}, },
}, },
@ -3960,24 +3960,29 @@ export class ProfileEmployeeController extends Controller {
nodeId: null, nodeId: null,
posNo: shortName, posNo: shortName,
salary: salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null, profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }

View file

@ -123,7 +123,7 @@ export class ProfileEmployeeTempController extends Controller {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: [ relations: [
"profileSalarys", "profileSalary",
"profileEducations", "profileEducations",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
@ -211,8 +211,8 @@ export class ProfileEmployeeTempController extends Controller {
: "", : "",
RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
SalaryAmount: SalaryAmount:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString()) ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
: "", : "",
Education: Education:
profile.profileEducations.length > 0 && profile.profileEducations.length > 0 &&
@ -221,8 +221,8 @@ export class ProfileEmployeeTempController extends Controller {
: "", : "",
AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", AppointText: profile.dateAppoint != null ? profile.dateAppoint : "",
SalaryDate: SalaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalarys[0].date)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date))
: "", : "",
PositionName: profile.position != null ? profile.position : "", PositionName: profile.position != null ? profile.position : "",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
@ -1481,20 +1481,20 @@ export class ProfileEmployeeTempController extends Controller {
) { ) {
const profiles = await this.profileRepo const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee") .createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.profileSalarys", "profileSalarys") .leftJoinAndSelect("profileEmployee.profileSalary", "profileSalary")
.select([ .select([
"profileEmployee.id", "profileEmployee.id",
"profileEmployee.prefix", "profileEmployee.prefix",
"profileEmployee.firstName", "profileEmployee.firstName",
"profileEmployee.lastName", "profileEmployee.lastName",
"profileEmployee.citizenId", "profileEmployee.citizenId",
"profileSalarys.position", "profileSalary.position",
"profileSalarys.posNo", "profileSalary.posNo",
"profileSalarys.date", "profileSalary.date",
]) ])
.andWhere( .andWhere(
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
? "profileSalarys.position LIKE :position" ? "profileSalary.position LIKE :position"
: "1=2", : "1=2",
{ {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
@ -1502,7 +1502,7 @@ export class ProfileEmployeeTempController extends Controller {
) )
.orWhere( .orWhere(
requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined
? "profileSalarys.posNo LIKE :posNo" ? "profileSalary.posNo LIKE :posNo"
: "1=2", : "1=2",
{ {
posNo: `%${requestBody.posNo}%`, posNo: `%${requestBody.posNo}%`,
@ -1512,8 +1512,8 @@ export class ProfileEmployeeTempController extends Controller {
const mapData = profiles.map((profile) => { const mapData = profiles.map((profile) => {
let profileSalary; let profileSalary;
if (profile.profileSalarys && profile.profileSalarys.length > 0) { if (profile.profileSalary && profile.profileSalary.length > 0) {
profileSalary = profile.profileSalarys.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;
}); });
} }
@ -1548,10 +1548,10 @@ export class ProfileEmployeeTempController extends Controller {
"posType", "posType",
"current_holders", "current_holders",
"current_holders.orgRoot", "current_holders.orgRoot",
"profileSalarys", "profileSalary",
], ],
order: { order: {
profileSalarys: { profileSalary: {
order: "DESC", order: "DESC",
}, },
}, },
@ -1663,8 +1663,7 @@ export class ProfileEmployeeTempController extends Controller {
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
.orgChild4Name, .orgChild4Name,
salary: salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
}; };
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }
@ -1697,7 +1696,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -1716,7 +1715,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -1735,7 +1734,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -1753,7 +1752,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType", "posType",
"posLevel", "posLevel",
"current_holders", "current_holders",
"profileSalarys", "profileSalary",
"current_holders.orgRoot", "current_holders.orgRoot",
"current_holders.orgChild1", "current_holders.orgChild1",
"current_holders.orgChild2", "current_holders.orgChild2",
@ -1810,8 +1809,8 @@ export class ProfileEmployeeTempController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = ""; let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) { if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalarys.sort( let _salary: any = item.profileSalary.sort(
(a, b) => (a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()), (b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
); );
@ -2401,7 +2400,7 @@ export class ProfileEmployeeTempController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3") .leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4") .leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions") .leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType") .leftJoinAndSelect("current_holder.posType", "posType")
@ -2499,9 +2498,9 @@ export class ProfileEmployeeTempController extends Controller {
} }
const amount = const amount =
item.current_holder == null || item.current_holder.profileSalarys.length == 0 item.current_holder == null || item.current_holder.profileSalary.length == 0
? null ? null
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount; : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date( let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
); );
@ -3267,7 +3266,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`), citizenId: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3279,7 +3278,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`), firstName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3291,7 +3290,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(), keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`), lastName: Like(`%${body.keyword}%`),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3302,7 +3301,7 @@ export class ProfileEmployeeTempController extends Controller {
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalarys"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
take, take,
}); });
@ -3353,8 +3352,8 @@ export class ProfileEmployeeTempController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = ""; let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) { if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalarys.sort( let _salary: any = item.profileSalary.sort(
(a, b) => (a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()), (b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
); );
@ -3542,18 +3541,23 @@ export class ProfileEmployeeTempController extends Controller {
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
_profile.nodeId = _profile.child4Id; _profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) { } else if (_profile.child3Id != null) {
_profile.node = 3; _profile.node = 3;
_profile.nodeId = _profile.child3Id; _profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) { } else if (_profile.child2Id != null) {
_profile.node = 2; _profile.node = 2;
_profile.nodeId = _profile.child2Id; _profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) { } else if (_profile.child1Id != null) {
_profile.node = 1; _profile.node = 1;
_profile.nodeId = _profile.child1Id; _profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) { } else if (_profile.rootId != null) {
_profile.node = 0; _profile.node = 0;
_profile.nodeId = _profile.rootId; _profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
} }
return new HttpSuccess(_profile); return new HttpSuccess(_profile);
} }

View file

@ -605,7 +605,7 @@ export class ProfileEmployee extends EntityBase {
next_holders: EmployeePosMaster[]; next_holders: EmployeePosMaster[];
@OneToMany(() => ProfileSalary, (v) => v.profileEmployee) @OneToMany(() => ProfileSalary, (v) => v.profileEmployee)
profileSalarys: ProfileSalary[]; profileSalary: ProfileSalary[];
@OneToMany(() => ProfileCertificate, (v) => v.profileEmployee) @OneToMany(() => ProfileCertificate, (v) => v.profileEmployee)
profileCertificates: ProfileCertificate[]; profileCertificates: ProfileCertificate[];
@ -786,6 +786,21 @@ export class ProfileEmployee extends EntityBase {
length: 5, length: 5,
}) })
currentZipCode: string; currentZipCode: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีรอบลงเวลาล่าสุด",
})
dutyTimeId: string;
@Column({
nullable: true,
type: "datetime",
comment: "รอบลงเวลาล่าสุด",
default: null,
})
dutyTimeEffectiveDate: Date;
} }
@Entity("profileEmployeeHistory") @Entity("profileEmployeeHistory")

View file

@ -175,7 +175,7 @@ export class ProfileSalary extends EntityBase {
@JoinColumn({ name: "profileId" }) @JoinColumn({ name: "profileId" })
profile: Profile; profile: Profile;
@ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.profileSalarys) @ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.profileSalary)
@JoinColumn({ name: "profileEmployeeId" }) @JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee; profileEmployee: ProfileEmployee;
} }

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileempAddDutyTimeId1730964715891 implements MigrationInterface {
name = 'UpdateTableProfileempAddDutyTimeId1730964715891'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dutyTimeId\` varchar(40) NULL COMMENT 'ไอดีรอบลงเวลาล่าสุด'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dutyTimeEffectiveDate\` datetime NULL COMMENT 'รอบลงเวลาล่าสุด'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dutyTimeId\` varchar(40) NULL COMMENT 'ไอดีรอบลงเวลาล่าสุด'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dutyTimeEffectiveDate\` datetime NULL COMMENT 'รอบลงเวลาล่าสุด'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dutyTimeEffectiveDate\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dutyTimeId\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dutyTimeEffectiveDate\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dutyTimeId\``);
}
}