sort edu by level

This commit is contained in:
kittapath 2025-01-06 23:58:24 +07:00
parent 4b05629c29
commit 587fe5d5b6
11 changed files with 229 additions and 266 deletions

View file

@ -625,8 +625,8 @@ export class CommandController extends Controller {
where: { id }, where: { id },
order: { order: {
commandSends: { commandSends: {
createdAt: "ASC" createdAt: "ASC",
} },
}, },
relations: ["commandSends", "commandSends.commandSendCCs"], relations: ["commandSends", "commandSends.commandSendCCs"],
}); });
@ -642,9 +642,7 @@ export class CommandController extends Controller {
lastName: item.lastName, lastName: item.lastName,
position: item.position, position: item.position,
org: item.org, org: item.org,
sendCC: item.commandSendCCs sendCC: item.commandSendCCs.sort((a, b) => a.name.localeCompare(b.name)).map((x) => x.name),
.sort((a, b) => a.name.localeCompare(b.name))
.map((x) => x.name),
profileId: item.profileId, profileId: item.profileId,
})); }));
return new HttpSuccess(_command); return new HttpSuccess(_command);
@ -1418,27 +1416,35 @@ export class CommandController extends Controller {
const shortName = const shortName =
profile?.current_holders.length == 0 profile?.current_holders.length == 0
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null && : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 != null &&
null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild4 != null
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null && : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
null &&
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild3 != null ?.orgChild3 != null
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null && : profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id,
) != null &&
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild2 != null ?.orgChild2 != null
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != : profile?.current_holders.find(
null && (x) => x.orgRevisionId == orgRevisionActive?.id,
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ) != null &&
?.orgChild1 != null profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id,
)?.orgChild1 != null
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != : profile?.current_holders.find(
null && (x) => x.orgRevisionId == orgRevisionActive?.id,
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ) != null &&
?.orgRoot != null profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id,
)?.orgRoot != null
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
: null; : null;
@ -1447,35 +1453,40 @@ export class CommandController extends Controller {
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgRoot; : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgRoot;
const child1 = const child1 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1; : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1;
const child2 = const child2 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2; : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2;
const child3 = const child3 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3; : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild3;
const child4 = const child4 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4; : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild4;
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
@ -1488,29 +1499,26 @@ export class CommandController extends Controller {
org: `${_child4}${_child3}${_child2}${_child1}${_root}`, org: `${_child4}${_child3}${_child2}${_child1}${_root}`,
fullName: `${x.prefix}${x.firstName} ${x.lastName}`, fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
citizenId: Extension.ToThaiNumber(x.citizenId), citizenId: Extension.ToThaiNumber(x.citizenId),
position: profile?.position position: profile?.position ? profile?.position : "-",
? profile?.position posLevel:
: "-", profile?.posType && profile?.posLevel
posLevel: profile?.posType && profile?.posLevel ? Extension.ToThaiNumber(
? Extension.ToThaiNumber(`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`) `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
: "-", )
posNo: shortName
? Extension.ToThaiNumber(shortName)
: "-",
amount: x.amount
? Extension.ToThaiNumber(x.amount.toString())
: "-", : "-",
posNo: shortName ? Extension.ToThaiNumber(shortName) : "-",
amount: x.amount ? Extension.ToThaiNumber(x.amount.toString()) : "-",
dateRetire: profile?.dateRetire dateRetire: profile?.dateRetire
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
: "-", : "-",
dateExecute: command.commandExcecuteDate dateExecute: command.commandExcecuteDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate)) ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),
)
: "-", : "-",
remark: x.remarkVertical remark: x.remarkVertical ? x.remarkVertical : "-",
? x.remarkVertical };
: "-" }),
}
})
); );
_command = { _command = {
issue: issue, issue: issue,
@ -1552,7 +1560,7 @@ export class CommandController extends Controller {
res && res.length > 3 res && res.length > 3
? `๔. ${res[3].name}.........${res[3].role}` ? `๔. ${res[3].name}.........${res[3].role}`
: "๔. ..........................กรรมการ", : "๔. ..........................กรรมการ",
persons: _persons persons: _persons,
}; };
} }
@ -2107,7 +2115,7 @@ export class CommandController extends Controller {
const _commandSend = await this.commandSendRepository.findOne({ const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: item.profileId ?? null_ profileId: item.profileId ?? null_,
}, },
}); });
if (!_commandSend) { if (!_commandSend) {
@ -2116,10 +2124,12 @@ export class CommandController extends Controller {
commandSend.prefix = item.prefix; commandSend.prefix = item.prefix;
commandSend.firstName = item.firstName; commandSend.firstName = item.firstName;
commandSend.lastName = item.lastName; commandSend.lastName = item.lastName;
commandSend.position = _posMasterDirector && _posMasterDirector.positions.length > 0 commandSend.position =
_posMasterDirector && _posMasterDirector.positions.length > 0
? _posMasterDirector.positions[0].positionName ? _posMasterDirector.positions[0].positionName
: null_; : null_;
commandSend.org = _posMasterDirector && _posMasterDirector.orgRoot commandSend.org =
_posMasterDirector && _posMasterDirector.orgRoot
? _posMasterDirector.orgRoot.orgRootName ? _posMasterDirector.orgRoot.orgRootName
: null_; : null_;
commandSend.profileId = item.profileId; commandSend.profileId = item.profileId;
@ -2149,10 +2159,9 @@ export class CommandController extends Controller {
await this.commandSendCCRepository.save(_dataSendCC); await this.commandSendCCRepository.save(_dataSendCC);
} }
} }
}) }),
) );
} }
} }
return new HttpSuccess(command.id); return new HttpSuccess(command.id);
} }
@ -3786,6 +3795,12 @@ export class CommandController extends Controller {
const eduHistory = new ProfileEducationHistory(); const eduHistory = new ProfileEducationHistory();
Object.assign(eduHistory, { ...profileEdu, id: undefined }); Object.assign(eduHistory, { ...profileEdu, id: undefined });
profileEdu.profileId = profile.id; profileEdu.profileId = profile.id;
const educationLevel = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileId: profile.id },
order: { level: "DESC" },
});
profileEdu.level = educationLevel == null ? 1 : educationLevel.level + 1;
await this.profileEducationRepo.save(profileEdu, { data: req }); await this.profileEducationRepo.save(profileEdu, { data: req });
setLogDataDiff(req, { before, after: profileEdu }); setLogDataDiff(req, { before, after: profileEdu });
eduHistory.profileEducationId = profileEdu.id; eduHistory.profileEducationId = profileEdu.id;

View file

@ -264,7 +264,7 @@ export class DPISController extends Controller {
dateLeaveStart: "ASC", dateLeaveStart: "ASC",
}, },
profileEducations: { profileEducations: {
degree: "ASC", level: "ASC",
}, },
}, },
}); });

View file

@ -42,7 +42,7 @@ import { HR_PERSONAL_EMP_FAMILY } from "../entities/HR_PERSONAL_EMP_FAMILY";
@Tags("UPLOAD") @Tags("UPLOAD")
@Security("bearerAuth") @Security("bearerAuth")
export class ImportDataController extends Controller { export class ImportDataController extends Controller {
private educationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private profileFamilyCoupleRepository = AppDataSource.getRepository(ProfileFamilyCouple); private profileFamilyCoupleRepository = AppDataSource.getRepository(ProfileFamilyCouple);
private profileFamilyMotherRepository = AppDataSource.getRepository(ProfileFamilyMother); private profileFamilyMotherRepository = AppDataSource.getRepository(ProfileFamilyMother);
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
@ -762,6 +762,12 @@ export class ImportDataController extends Controller {
select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"], select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"],
}); });
const educationLevel = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileId: _item.id },
order: { level: "DESC" },
});
// educations = await []; // educations = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
@ -781,6 +787,7 @@ export class ImportDataController extends Controller {
: null_; : null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_; // endDate = endDate ? new Date(endDate, 0, 1) : null_;
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileId = _item.id; education.profileId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE; education.institute = item.INSTITUE;
@ -794,16 +801,16 @@ export class ImportDataController extends Controller {
education.lastUpdatedAt = new Date(); education.lastUpdatedAt = new Date();
// await educations.push(await education); // await educations.push(await education);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.educationRepository.save(await education); await this.profileEducationRepo.save(await education);
}), }),
); );
// await this.educationRepository.save(educations); // await this.profileEducationRepo.save(educations);
// educations = await []; // educations = await [];
}), }),
); );
// } // }
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); // console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations); // await this.profileEducationRepo.save(educations);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -838,6 +845,12 @@ export class ImportDataController extends Controller {
select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"], select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"],
}); });
const educationLevel = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileEmployeeId: _item.id },
order: { level: "DESC" },
});
educations = await []; educations = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
@ -857,6 +870,7 @@ export class ImportDataController extends Controller {
: null_; : null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_; // endDate = endDate ? new Date(endDate, 0, 1) : null_;
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileEmployeeId = _item.id; education.profileEmployeeId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE; education.institute = item.INSTITUE;
@ -870,15 +884,15 @@ export class ImportDataController extends Controller {
education.lastUpdatedAt = new Date(); education.lastUpdatedAt = new Date();
// educations.push(education); // educations.push(education);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.educationRepository.save(education); await this.profileEducationRepo.save(education);
}), }),
); );
// await this.educationRepository.save(educations); // await this.profileEducationRepo.save(educations);
}), }),
); );
// } // }
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); // console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations); // await this.profileEducationRepo.save(educations);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -63,6 +63,13 @@ export class InsigniaController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
} }
const _insignia = await this.insigniaRepository.findOne({
select: ["id", "level", "insigniaTypeId"],
where: { insigniaTypeId: requestBody.insigniaTypeId },
order: { level: "DESC" },
});
insignia.level = _insignia == null ? 1 : _insignia.level + 1;
insignia.createdUserId = request.user.sub; insignia.createdUserId = request.user.sub;
insignia.createdFullName = request.user.name; insignia.createdFullName = request.user.name;
insignia.lastUpdateUserId = request.user.sub; insignia.lastUpdateUserId = request.user.sub;
@ -131,6 +138,19 @@ export class InsigniaController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้");
} }
await this.insigniaRepository.remove(delInsignia); await this.insigniaRepository.remove(delInsignia);
const insignia = await this.insigniaRepository.find({
select: ["id", "level", "insigniaTypeId"],
where: { insigniaTypeId: delInsignia.insigniaTypeId },
order: { level: "DESC" },
});
const sortLevel = insignia.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.insigniaRepository.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -284,7 +304,7 @@ export class InsigniaController extends Controller {
} }
const insignia = await this.insigniaRepository.find({ const insignia = await this.insigniaRepository.find({
select: ["id", "level"], select: ["id", "level", "insigniaTypeId"],
where: { insigniaTypeId: insigniaTypeId }, where: { insigniaTypeId: insigniaTypeId },
}); });

View file

@ -99,9 +99,8 @@ export class ProfileController extends Controller {
private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory); private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory);
private trainingRepository = AppDataSource.getRepository(ProfileTraining); private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary); private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private provinceRepo = AppDataSource.getRepository(Province); private provinceRepo = AppDataSource.getRepository(Province);
private districtRepo = AppDataSource.getRepository(District); private districtRepo = AppDataSource.getRepository(District);
private subDistrictRepo = AppDataSource.getRepository(SubDistrict); private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
@ -254,10 +253,10 @@ export class ProfileController extends Controller {
}, },
]; ];
const educations = await this.educationRepository.find({ const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id }, where: { profileId: id },
order: { startDate: "ASC" }, order: { level: "ASC" },
}); });
const Education = const Education =
educations && educations.length > 0 educations && educations.length > 0
@ -544,11 +543,11 @@ export class ProfileController extends Controller {
}, },
]; ];
const education_raw = await this.educationRepository.find({ const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id }, where: { profileId: id },
// order: { lastUpdatedAt: "DESC" }, // order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
const educations = const educations =
education_raw.length > 0 education_raw.length > 0
@ -5590,7 +5589,7 @@ export class ProfileController extends Controller {
// order: "DESC", // order: "DESC",
// }, // },
profileEducations: { profileEducations: {
createdAt: "DESC", level: "ASC",
}, },
}, },
}); });
@ -5772,7 +5771,7 @@ export class ProfileController extends Controller {
salary: profile ? profile.amount : null, salary: profile ? profile.amount : null,
education: education:
profile && profile.profileEducations.length > 0 profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` ? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-", : "-",
}; };
@ -5829,7 +5828,7 @@ export class ProfileController extends Controller {
@Get("citizenid/position/{id}") @Get("citizenid/position/{id}")
async getProfileByCitizenId(@Request() request: RequestWithUser, @Path() id: string) { async getProfileByCitizenId(@Request() request: RequestWithUser, @Path() id: string) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { citizenId: id, isActive: true }, where: { citizenId: id, isActive: true, profileEducations: { isUse: true } },
relations: [ relations: [
"posLevel", "posLevel",
"posType", "posType",
@ -5840,11 +5839,15 @@ export class ProfileController extends Controller {
"current_holders.orgChild3", "current_holders.orgChild3",
"current_holders.orgChild4", "current_holders.orgChild4",
"profileSalary", "profileSalary",
"profileEducations",
], ],
order: { order: {
profileSalary: { profileSalary: {
order: "DESC", order: "DESC",
}, },
profileEducations: {
level: "ASC",
},
}, },
}); });
if (!profile) { if (!profile) {
@ -5934,6 +5937,10 @@ export class ProfileController extends Controller {
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,
education:
profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "",
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
@ -5984,7 +5991,7 @@ export class ProfileController extends Controller {
], ],
order: { order: {
profileEducations: { profileEducations: {
createdAt: "DESC", level: "ASC",
}, },
}, },
}); });
@ -6073,7 +6080,7 @@ export class ProfileController extends Controller {
salary: profile.amount, salary: profile.amount,
education: education:
profile && profile.profileEducations.length > 0 profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` ? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-", : "-",
}; };
@ -6396,9 +6403,9 @@ export class ProfileController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id }, where: { profileId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {
@ -6444,28 +6451,6 @@ export class ProfileController extends Controller {
latestProfileEducation != null && latestProfileEducation.educationLevel != null latestProfileEducation != null && latestProfileEducation.educationLevel != null
? latestProfileEducation.educationLevel ? latestProfileEducation.educationLevel
: null, : null,
// ? {
// id: latestProfileEducation.id,
// degree: latestProfileEducation.degree,
// country: latestProfileEducation.country,
// duration: latestProfileEducation.duration,
// durationYear: latestProfileEducation.durationYear,
// field: latestProfileEducation.field,
// finishDate: latestProfileEducation.finishDate,
// fundName: latestProfileEducation.fundName,
// gpa: latestProfileEducation.gpa,
// institute: latestProfileEducation.institute,
// other: latestProfileEducation.other,
// startDate: latestProfileEducation.startDate,
// endDate: latestProfileEducation.endDate,
// educationLevel: latestProfileEducation.educationLevel,
// positionPath: latestProfileEducation.positionPath,
// positionPathId: latestProfileEducation.positionPathId,
// isDate: latestProfileEducation.isDate,
// isEducation: latestProfileEducation.isEducation,
// note: latestProfileEducation.note,
// }
// : null,
}; };
}), }),
); );
@ -7922,9 +7907,9 @@ export class ProfileController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id }, where: { profileId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {

View file

@ -44,7 +44,7 @@ export class ProfileEducationsController extends Controller {
} }
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -59,7 +59,7 @@ export class ProfileEducationsController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -133,23 +133,18 @@ export class ProfileEducationsController extends Controller {
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(history, { ...data, id: undefined }); Object.assign(history, { ...data, id: undefined });
const education = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileId: body.profileId },
order: { level: "DESC" },
});
data.level = education == null ? 1 : education.level + 1;
await this.profileEducationRepo.save(data, { data: req }); await this.profileEducationRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data }); setLogDataDiff(req, { before, after: data });
history.profileEducationId = data.id; history.profileEducationId = data.id;
await this.profileEducationHistoryRepo.save(history, { data: req }); await this.profileEducationHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history }); //setLogDataDiff(req, { before, after: history });
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileId: body.profileId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -187,17 +182,6 @@ export class ProfileEducationsController extends Controller {
// setLogDataDiff(req, { before: before_null, after: history }), // setLogDataDiff(req, { before: before_null, after: history }),
]); ]);
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileId: record.profileId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -220,8 +204,9 @@ export class ProfileEducationsController extends Controller {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileId"],
where: { profileId: record?.profileId }, where: { profileId: record?.profileId },
order: { level: "ASC" },
}); });
const sortLevel = education.map((data, i) => ({ const sortLevel = education.map((data, i) => ({
@ -240,7 +225,10 @@ export class ProfileEducationsController extends Controller {
* *
*/ */
@Put("sort/{profileId}") @Put("sort/{profileId}")
async Sort(@Path() profileId: string, @Body() requestBody: { id: string[] }) { async Sort(
@Path() profileId: string,
@Body() requestBody: { data: { id: string; isUse: boolean }[] },
) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileId }, where: { id: profileId },
}); });
@ -249,13 +237,14 @@ export class ProfileEducationsController extends Controller {
} }
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileId", "isUse"],
where: { profileId: profileId }, where: { profileId: profileId },
}); });
const sortLevel = education.map((data) => ({ const sortLevel = education.map((data) => ({
id: data.id, id: data.id,
level: requestBody.id.indexOf(data.id) + 1, level: requestBody.data.findIndex((x) => x.id == data.id) + 1,
isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false,
})); }));
await this.profileEducationRepo.save(sortLevel); await this.profileEducationRepo.save(sortLevel);

View file

@ -139,23 +139,18 @@ export class ProfileEducationsEmployeeController extends Controller {
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(history, { ...data, id: undefined }); Object.assign(history, { ...data, id: undefined });
const education = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: body.profileEmployeeId },
order: { level: "DESC" },
});
data.level = education == null ? 1 : education.level + 1;
await this.profileEducationRepo.save(data, { data: req }); await this.profileEducationRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data }); setLogDataDiff(req, { before, after: data });
history.profileEducationId = data.id; history.profileEducationId = data.id;
await this.profileEducationHistoryRepo.save(history, { data: req }); await this.profileEducationHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history }); //setLogDataDiff(req, { before, after: history });
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileEmployeeId: body.profileEmployeeId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -197,17 +192,6 @@ export class ProfileEducationsEmployeeController extends Controller {
setLogDataDiff(req, { before, after: history }), setLogDataDiff(req, { before, after: history }),
]); ]);
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileEmployeeId: record.profileEmployeeId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -236,8 +220,9 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: _record?.profileEmployeeId }, where: { profileEmployeeId: _record?.profileEmployeeId },
order: { level: "ASC" },
}); });
const sortLevel = education.map((data, i) => ({ const sortLevel = education.map((data, i) => ({
@ -256,7 +241,10 @@ export class ProfileEducationsEmployeeController extends Controller {
* *
*/ */
@Put("sort/{profileId}") @Put("sort/{profileId}")
async Sort(@Path() profileId: string, @Body() requestBody: { id: string[] }) { async Sort(
@Path() profileId: string,
@Body() requestBody: { data: { id: string; isUse: boolean }[] },
) {
const profile = await this.profileEmployeeRepo.findOne({ const profile = await this.profileEmployeeRepo.findOne({
where: { id: profileId }, where: { id: profileId },
}); });
@ -265,13 +253,14 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
}); });
const sortLevel = education.map((data) => ({ const sortLevel = education.map((data) => ({
id: data.id, id: data.id,
level: requestBody.id.indexOf(data.id) + 1, level: requestBody.data.findIndex((x) => x.id == data.id) + 1,
isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false,
})); }));
await this.profileEducationRepo.save(sortLevel); await this.profileEducationRepo.save(sortLevel);

View file

@ -42,7 +42,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -59,7 +59,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -129,22 +129,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(history, { ...data, id: undefined }); Object.assign(history, { ...data, id: undefined });
const education = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: body.profileEmployeeId },
order: { level: "DESC" },
});
data.level = education == null ? 1 : education.level + 1;
await this.profileEducationRepo.save(data, { data: req }); await this.profileEducationRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data }); setLogDataDiff(req, { before, after: data });
history.profileEducationId = data.id; history.profileEducationId = data.id;
await this.profileEducationHistoryRepo.save(history, { data: req }); await this.profileEducationHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history }); //setLogDataDiff(req, { before, after: history });
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileEmployeeId: body.profileEmployeeId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -182,17 +178,6 @@ export class ProfileEducationsEmployeeTempController extends Controller {
// setLogDataDiff(req, { before: before_null, after: history }), // setLogDataDiff(req, { before: before_null, after: history }),
]); ]);
const education = await this.profileEducationRepo.find({
select: ["id", "level"],
where: { profileEmployeeId: record.profileEmployeeId },
});
const sortLevel = education.map((data, i) => ({
id: data.id,
level: i + 1,
}));
await this.profileEducationRepo.save(sortLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -214,8 +199,9 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: _record?.profileEmployeeId }, where: { profileEmployeeId: _record?.profileEmployeeId },
order: { level: "ASC" },
}); });
const sortLevel = education.map((data, i) => ({ const sortLevel = education.map((data, i) => ({
@ -234,7 +220,10 @@ export class ProfileEducationsEmployeeTempController extends Controller {
* *
*/ */
@Put("sort/{profileId}") @Put("sort/{profileId}")
async Sort(@Path() profileId: string, @Body() requestBody: { id: string[] }) { async Sort(
@Path() profileId: string,
@Body() requestBody: { data: { id: string; isUse: boolean }[] },
) {
const profile = await this.profileEmployeeRepo.findOne({ const profile = await this.profileEmployeeRepo.findOne({
where: { id: profileId }, where: { id: profileId },
}); });
@ -243,13 +232,14 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
const education = await this.profileEducationRepo.find({ const education = await this.profileEducationRepo.find({
select: ["id", "level"], select: ["id", "level", "profileEmployeeId"],
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
}); });
const sortLevel = education.map((data) => ({ const sortLevel = education.map((data) => ({
id: data.id, id: data.id,
level: requestBody.id.indexOf(data.id) + 1, level: requestBody.data.findIndex((x) => x.id == data.id) + 1,
isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false,
})); }));
await this.profileEducationRepo.save(sortLevel); await this.profileEducationRepo.save(sortLevel);

View file

@ -91,7 +91,6 @@ export class ProfileEmployeeController extends Controller {
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private trainingRepository = AppDataSource.getRepository(ProfileTraining); private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary); private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private orgRootRepository = AppDataSource.getRepository(OrgRoot); private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1); private child1Repository = AppDataSource.getRepository(OrgChild1);
@ -105,7 +104,7 @@ export class ProfileEmployeeController extends Controller {
private employmentHistoryRepository = AppDataSource.getRepository( private employmentHistoryRepository = AppDataSource.getRepository(
ProfileEmployeeEmploymentHistory, ProfileEmployeeEmploymentHistory,
); );
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
private positionRepository = AppDataSource.getRepository(Position); private positionRepository = AppDataSource.getRepository(Position);
@ -226,10 +225,10 @@ export class ProfileEmployeeController extends Controller {
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
const educations = await this.educationRepository.find({ const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" },
}); });
const Education = const Education =
educations && educations.length > 0 educations && educations.length > 0
@ -512,11 +511,11 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const education_raw = await this.educationRepository.find({ const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
// order: { lastUpdatedAt: "DESC" }, // order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
const educations = const educations =
education_raw.length > 0 education_raw.length > 0
@ -2462,9 +2461,9 @@ export class ProfileEmployeeController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id }, where: { profileEmployeeId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {
@ -2510,28 +2509,6 @@ export class ProfileEmployeeController extends Controller {
latestProfileEducation != null && latestProfileEducation.educationLevel != null latestProfileEducation != null && latestProfileEducation.educationLevel != null
? latestProfileEducation.educationLevel ? latestProfileEducation.educationLevel
: null, : null,
// ? {
// id: latestProfileEducation.id,
// degree: latestProfileEducation.degree,
// country: latestProfileEducation.country,
// duration: latestProfileEducation.duration,
// durationYear: latestProfileEducation.durationYear,
// field: latestProfileEducation.field,
// finishDate: latestProfileEducation.finishDate,
// fundName: latestProfileEducation.fundName,
// gpa: latestProfileEducation.gpa,
// institute: latestProfileEducation.institute,
// other: latestProfileEducation.other,
// startDate: latestProfileEducation.startDate,
// endDate: latestProfileEducation.endDate,
// educationLevel: latestProfileEducation.educationLevel,
// positionPath: latestProfileEducation.positionPath,
// positionPathId: latestProfileEducation.positionPathId,
// isDate: latestProfileEducation.isDate,
// isEducation: latestProfileEducation.isEducation,
// note: latestProfileEducation.note,
// }
// : null,
}; };
}), }),
); );
@ -4103,9 +4080,9 @@ export class ProfileEmployeeController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id }, where: { profileEmployeeId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {
@ -4169,7 +4146,7 @@ export class ProfileEmployeeController extends Controller {
// order: "DESC", // order: "DESC",
// }, // },
profileEducations: { profileEducations: {
createdAt: "DESC", level: "ASC",
}, },
}, },
}); });
@ -4295,7 +4272,7 @@ export class ProfileEmployeeController extends Controller {
salary: profile.amount, salary: profile.amount,
education: education:
profile && profile.profileEducations.length > 0 profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` ? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-", : "-",
}; };

View file

@ -90,7 +90,6 @@ export class ProfileEmployeeTempController extends Controller {
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private trainingRepository = AppDataSource.getRepository(ProfileTraining); private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary); private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private orgRootRepository = AppDataSource.getRepository(OrgRoot); private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1); private child1Repository = AppDataSource.getRepository(OrgChild1);
@ -104,7 +103,7 @@ export class ProfileEmployeeTempController extends Controller {
private employmentHistoryRepository = AppDataSource.getRepository( private employmentHistoryRepository = AppDataSource.getRepository(
ProfileEmployeeEmploymentHistory, ProfileEmployeeEmploymentHistory,
); );
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
/** /**
@ -223,10 +222,10 @@ export class ProfileEmployeeTempController extends Controller {
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
const educations = await this.educationRepository.find({ const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" },
}); });
const Education = const Education =
educations && educations.length > 0 educations && educations.length > 0
@ -509,11 +508,11 @@ export class ProfileEmployeeTempController extends Controller {
}, },
]; ];
const education_raw = await this.educationRepository.find({ const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
// order: { lastUpdatedAt: "DESC" }, // order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" }, order: { level: "ASC" },
}); });
const educations = const educations =
education_raw.length > 0 education_raw.length > 0
@ -2027,9 +2026,9 @@ export class ProfileEmployeeTempController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id }, where: { profileEmployeeId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {
@ -2075,28 +2074,6 @@ export class ProfileEmployeeTempController extends Controller {
latestProfileEducation != null && latestProfileEducation.educationLevel != null latestProfileEducation != null && latestProfileEducation.educationLevel != null
? latestProfileEducation.educationLevel ? latestProfileEducation.educationLevel
: null, : null,
// ? {
// id: latestProfileEducation.id,
// degree: latestProfileEducation.degree,
// country: latestProfileEducation.country,
// duration: latestProfileEducation.duration,
// durationYear: latestProfileEducation.durationYear,
// field: latestProfileEducation.field,
// finishDate: latestProfileEducation.finishDate,
// fundName: latestProfileEducation.fundName,
// gpa: latestProfileEducation.gpa,
// institute: latestProfileEducation.institute,
// other: latestProfileEducation.other,
// startDate: latestProfileEducation.startDate,
// endDate: latestProfileEducation.endDate,
// educationLevel: latestProfileEducation.educationLevel,
// positionPath: latestProfileEducation.positionPath,
// positionPathId: latestProfileEducation.positionPathId,
// isDate: latestProfileEducation.isDate,
// isEducation: latestProfileEducation.isEducation,
// note: latestProfileEducation.note,
// }
// : null,
}; };
}), }),
); );
@ -3556,9 +3533,9 @@ export class ProfileEmployeeTempController extends Controller {
(x) => x.orgRevisionId == findRevision.id, (x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo; )?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({ const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id }, where: { profileEmployeeId: item.id },
order: { endDate: "DESC" }, order: { level: "ASC" },
}); });
return { return {
@ -3619,7 +3596,7 @@ export class ProfileEmployeeTempController extends Controller {
], ],
order: { order: {
profileEducations: { profileEducations: {
createdAt: "DESC", level: "ASC",
}, },
}, },
}); });
@ -3744,7 +3721,7 @@ export class ProfileEmployeeTempController extends Controller {
salary: profile.amount, salary: profile.amount,
education: education:
profile && profile.profileEducations.length > 0 profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` ? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-", : "-",
}; };

View file

@ -161,6 +161,13 @@ export class ProfileEducation extends EntityBase {
}) })
isEducation: boolean; isEducation: boolean;
@Column({
nullable: true,
comment: "ใช้ประวัติการศึกษา",
default: null,
})
isUse: boolean;
@Column({ @Column({
nullable: true, nullable: true,
length: 40, length: 40,