update issue #1436 (fix report kk1)

This commit is contained in:
Bright 2025-04-26 14:03:52 +07:00
parent 921e23f81a
commit 1eadad89da

View file

@ -924,6 +924,12 @@ export class ProfileController extends Controller {
"registrationDistrict",
"registrationProvince",
"profileAvatars",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
order: {
profileAvatars: { createdAt: "ASC" },
@ -934,13 +940,6 @@ export class ProfileController extends Controller {
let ImgUrl: any = null;
let _ImgUrl: any = [];
if (profiles?.avatar != null && profiles?.avatarName != null) {
// await new CallAPI()
// .GetData(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
// .then(async (x) => {
// ImgUrl = x.downloadUrl;
// })
// .catch();
let req_: any = req;
const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", "");
@ -975,18 +974,7 @@ export class ProfileController extends Controller {
ImgUrl = response_.data.downloadUrl;
} catch {}
}
const profileOc = await this.profileRepo.findOne({
relations: [
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: { id: id },
});
if (!profileOc) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const orgRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
});
@ -1010,39 +998,39 @@ export class ProfileController extends Controller {
});
const root =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
const child1 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
const child2 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
const child3 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
const child4 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
// Construct org path
let _root = root?.orgRootName;
@ -1058,7 +1046,7 @@ export class ProfileController extends Controller {
});
const certs =
cert_raw.length > 0
? cert_raw.slice(-2).map((item) => ({
? cert_raw.map((item) => ({
certificateType: item.certificateType ?? null,
issuer: item.issuer ?? null,
certificateNo: item.certificateNo ? Extension.ToThaiNumber(item.certificateNo) : null,
@ -1091,7 +1079,7 @@ export class ProfileController extends Controller {
});
const trainings =
training_raw.length > 0
? training_raw.slice(-2).map((item) => ({
? training_raw.map((item) => ({
institute: item.department ?? "",
start:
item.startDate == null
@ -1128,7 +1116,7 @@ export class ProfileController extends Controller {
});
const disciplines =
discipline_raw.length > 0
? discipline_raw.slice(-2).map((item) => ({
? discipline_raw.map((item) => ({
disciplineYear: item.refCommandDate
? Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString())
: null,
@ -1143,47 +1131,38 @@ export class ProfileController extends Controller {
},
];
const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
// order: { lastUpdatedAt: "DESC" },
order: { level: "ASC" },
});
const education_raw = await this.profileEducationRepo
.createQueryBuilder("education")
.where("education.profileId = :profileId", { profileId: id })
.orderBy("CASE WHEN education.isEducation = true THEN 1 ELSE 2 END", "ASC")
.addOrderBy("education.level", "ASC")
.getMany();
const educations =
education_raw.length > 0
? education_raw.slice(-2).map((item) => ({
? education_raw.map((item) => ({
institute: item.institute,
start:
item.startDate == null
? ""
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
end:
item.endDate == null
? ""
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: "",
level: item.educationLevel ?? "",
date:
item.isDate
? item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: ""
: item.startDate && item.endDate
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
: "",
degree: item.degree ? `${item.degree} ${item.field ? item.field : ""}` : "",
field: item.field ?? "-",
}))
: [
{
institute: "-",
start: "-",
end: "-",
date: "-",
level: "-",
degree: "-",
field: "-",
},
];
const salary_raw = await this.salaryRepo.find({
select: [
"commandDateAffect",
"positionName",
"posNoAbb",
"posNo",
"positionType",
"positionLevel",
@ -1207,7 +1186,9 @@ export class ProfileController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: null,
position: item.positionName != null ? Extension.ToThaiNumber(item.positionName) : null,
posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null,
posNo: item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`)
: null,
salary:
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
@ -1447,10 +1428,8 @@ export class ProfileController extends Controller {
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
posNo: item.posNoAbb
? Extension.ToThaiNumber(item.posNoAbb)
: "" + item.posNo
? Extension.ToThaiNumber(item.posNo)
posNo: item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`)
: "",
position: item.positionName,
posType: item.positionType,
@ -1676,6 +1655,9 @@ export class ProfileController extends Controller {
appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
positionDate: positionList.length > 0
? positionList[positionList.length-1].commandDateAffect
: "",
citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName: