fix
This commit is contained in:
parent
8278d9ddff
commit
293effa89a
1 changed files with 454 additions and 454 deletions
|
|
@ -395,477 +395,477 @@ export class ProfileController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * รายงาน ก.ก.1 (ข้าราชการ)
|
||||
// *
|
||||
// * @summary รายงาน ก.ก.1 (ข้าราชการ)
|
||||
// *
|
||||
// * @param {string} id Id โปรไฟล์
|
||||
// */
|
||||
// @Get("kk1/{id}")
|
||||
// public async getKk1(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
// const profiles = await this.profileRepo.findOne({
|
||||
// relations: ["currentSubDistrict", "currentDistrict", "currentProvince", "profileAvatars"],
|
||||
// order: {
|
||||
// profileAvatars: { createdAt: "ASC" },
|
||||
// },
|
||||
// where: { id: id },
|
||||
// });
|
||||
// if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
// 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();
|
||||
/**
|
||||
* รายงาน ก.ก.1 (ข้าราชการ)
|
||||
*
|
||||
* @summary รายงาน ก.ก.1 (ข้าราชการ)
|
||||
*
|
||||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kk1/{id}")
|
||||
public async getKk1(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.findOne({
|
||||
relations: ["currentSubDistrict", "currentDistrict", "currentProvince", "profileAvatars"],
|
||||
order: {
|
||||
profileAvatars: { createdAt: "ASC" },
|
||||
},
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
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 ", "");
|
||||
let req_: any = req;
|
||||
const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", "");
|
||||
|
||||
// await Promise.all(
|
||||
// await profiles.profileAvatars.slice(-7).map(async (x, i) => {
|
||||
// if (x == null) {
|
||||
// _ImgUrl[i] = null;
|
||||
// } else {
|
||||
// const url = process.env.API_URL + `/salary/file/${x?.avatar}/${x?.avatarName}`;
|
||||
// try {
|
||||
// const response_ = await axios.get(url, {
|
||||
// headers: {
|
||||
// Authorization: `${token_}`,
|
||||
// "Content-Type": "application/json",
|
||||
// api_key: process.env.API_KEY,
|
||||
// },
|
||||
// });
|
||||
// _ImgUrl[i] = response_.data.downloadUrl;
|
||||
// } catch {}
|
||||
// }
|
||||
// }),
|
||||
// );
|
||||
// const url = process.env.API_URL + `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`;
|
||||
// try {
|
||||
// const response_ = await axios.get(url, {
|
||||
// headers: {
|
||||
// Authorization: `${token_}`,
|
||||
// "Content-Type": "application/json",
|
||||
// api_key: process.env.API_KEY,
|
||||
// },
|
||||
// });
|
||||
// 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 },
|
||||
// });
|
||||
await Promise.all(
|
||||
await profiles.profileAvatars.slice(-7).map(async (x, i) => {
|
||||
if (x == null) {
|
||||
_ImgUrl[i] = null;
|
||||
} else {
|
||||
const url = process.env.API_URL + `/salary/file/${x?.avatar}/${x?.avatarName}`;
|
||||
try {
|
||||
const response_ = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `${token_}`,
|
||||
"Content-Type": "application/json",
|
||||
api_key: process.env.API_KEY,
|
||||
},
|
||||
});
|
||||
_ImgUrl[i] = response_.data.downloadUrl;
|
||||
} catch {}
|
||||
}
|
||||
}),
|
||||
);
|
||||
const url = process.env.API_URL + `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`;
|
||||
try {
|
||||
const response_ = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `${token_}`,
|
||||
"Content-Type": "application/json",
|
||||
api_key: process.env.API_KEY,
|
||||
},
|
||||
});
|
||||
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 },
|
||||
});
|
||||
|
||||
// const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({
|
||||
// where: { profileId: id },
|
||||
// select: ["couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld"],
|
||||
// order: { lastUpdatedAt: "DESC" },
|
||||
// });
|
||||
const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({
|
||||
where: { profileId: id },
|
||||
select: ["couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
// const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({
|
||||
// where: { profileId: id },
|
||||
// select: ["motherPrefix", "motherFirstName", "motherLastName"],
|
||||
// order: { lastUpdatedAt: "DESC" },
|
||||
// });
|
||||
const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({
|
||||
where: { profileId: id },
|
||||
select: ["motherPrefix", "motherFirstName", "motherLastName"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
// const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({
|
||||
// where: { profileId: id },
|
||||
// select: ["fatherPrefix", "fatherFirstName", "fatherLastName"],
|
||||
// order: { lastUpdatedAt: "DESC" },
|
||||
// });
|
||||
const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({
|
||||
where: { profileId: id },
|
||||
select: ["fatherPrefix", "fatherFirstName", "fatherLastName"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
// const root =
|
||||
// profileOc.current_holders == null ||
|
||||
// profileOc.current_holders.length == 0 ||
|
||||
// profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
// ? null
|
||||
// : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
|
||||
const root =
|
||||
profileOc.current_holders == null ||
|
||||
profileOc.current_holders.length == 0 ||
|
||||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profileOc.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
|
||||
// ? null
|
||||
// : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
|
||||
const child1 =
|
||||
profileOc.current_holders == null ||
|
||||
profileOc.current_holders.length == 0 ||
|
||||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profileOc.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
|
||||
// ? null
|
||||
// : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
|
||||
const child2 =
|
||||
profileOc.current_holders == null ||
|
||||
profileOc.current_holders.length == 0 ||
|
||||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profileOc.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
|
||||
// ? null
|
||||
// : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
|
||||
const child3 =
|
||||
profileOc.current_holders == null ||
|
||||
profileOc.current_holders.length == 0 ||
|
||||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profileOc.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
|
||||
// ? null
|
||||
// : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
|
||||
const child4 =
|
||||
profileOc.current_holders == null ||
|
||||
profileOc.current_holders.length == 0 ||
|
||||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
|
||||
|
||||
// // Construct org path
|
||||
// const _root = root ? `${root.orgRootName}` : "";
|
||||
// const _child1 = child1 ? `${child1.orgChild1Name}/` : "";
|
||||
// const _child2 = child2 ? `${child2.orgChild2Name}/` : "";
|
||||
// const _child3 = child3 ? `${child3.orgChild3Name}/` : "";
|
||||
// const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
|
||||
// Construct org path
|
||||
const _root = root ? `${root.orgRootName}` : "";
|
||||
const _child1 = child1 ? `${child1.orgChild1Name}/` : "";
|
||||
const _child2 = child2 ? `${child2.orgChild2Name}/` : "";
|
||||
const _child3 = child3 ? `${child3.orgChild3Name}/` : "";
|
||||
const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
|
||||
|
||||
// const cert_raw = await this.certificateRepository.find({
|
||||
// where: { profileId: id },
|
||||
// select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
||||
// order: { createdAt: "ASC" },
|
||||
// });
|
||||
// const certs =
|
||||
// cert_raw.length > 0
|
||||
// ? cert_raw.slice(-2).map((item) => ({
|
||||
// certificateType: item.certificateType ?? null,
|
||||
// issuer: item.issuer ?? null,
|
||||
// certificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
|
||||
// issueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null,
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// certificateType: "-",
|
||||
// issuer: "-",
|
||||
// certificateNo: "-",
|
||||
// issueDate: "-",
|
||||
// },
|
||||
// ];
|
||||
// const training_raw = await this.trainingRepository.find({
|
||||
// select: ["startDate", "endDate", "place", "department", "name"],
|
||||
// where: { profileId: id },
|
||||
// order: { createdAt: "ASC" },
|
||||
// });
|
||||
// const trainings =
|
||||
// training_raw.length > 0
|
||||
// ? training_raw.slice(-2).map((item) => ({
|
||||
// institute: item.department ?? "",
|
||||
// start:
|
||||
// item.startDate == null
|
||||
// ? ""
|
||||
// : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)),
|
||||
// end:
|
||||
// item.endDate == null
|
||||
// ? ""
|
||||
// : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
|
||||
// date:
|
||||
// item.startDate && item.endDate
|
||||
// ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
||||
// : "",
|
||||
// level: "",
|
||||
// degree: item.name,
|
||||
// field: "",
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// institute: "-",
|
||||
// start: "-",
|
||||
// end: "-",
|
||||
// date: "-",
|
||||
// level: "-",
|
||||
// degree: "-",
|
||||
// field: "-",
|
||||
// },
|
||||
// ];
|
||||
const cert_raw = await this.certificateRepository.find({
|
||||
where: { profileId: id },
|
||||
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const certs =
|
||||
cert_raw.length > 0
|
||||
? cert_raw.slice(-2).map((item) => ({
|
||||
certificateType: item.certificateType ?? null,
|
||||
issuer: item.issuer ?? null,
|
||||
certificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
|
||||
issueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
certificateType: "-",
|
||||
issuer: "-",
|
||||
certificateNo: "-",
|
||||
issueDate: "-",
|
||||
},
|
||||
];
|
||||
const training_raw = await this.trainingRepository.find({
|
||||
select: ["startDate", "endDate", "place", "department", "name"],
|
||||
where: { profileId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const trainings =
|
||||
training_raw.length > 0
|
||||
? training_raw.slice(-2).map((item) => ({
|
||||
institute: item.department ?? "",
|
||||
start:
|
||||
item.startDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)),
|
||||
end:
|
||||
item.endDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
|
||||
date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
||||
: "",
|
||||
level: "",
|
||||
degree: item.name,
|
||||
field: "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
institute: "-",
|
||||
start: "-",
|
||||
end: "-",
|
||||
date: "-",
|
||||
level: "-",
|
||||
degree: "-",
|
||||
field: "-",
|
||||
},
|
||||
];
|
||||
|
||||
// const discipline_raw = await this.disciplineRepository.find({
|
||||
// select: ["refCommandDate", "refCommandNo", "detail"],
|
||||
// where: { profileId: id },
|
||||
// order: { createdAt: "ASC" },
|
||||
// });
|
||||
// const disciplines =
|
||||
// discipline_raw.length > 0
|
||||
// ? discipline_raw.slice(-2).map((item) => ({
|
||||
// disciplineYear:
|
||||
// Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ??
|
||||
// null,
|
||||
// disciplineDetail: item.detail ?? null,
|
||||
// refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// disciplineYear: "-",
|
||||
// disciplineDetail: "-",
|
||||
// refNo: "-",
|
||||
// },
|
||||
// ];
|
||||
const discipline_raw = await this.disciplineRepository.find({
|
||||
select: ["refCommandDate", "refCommandNo", "detail"],
|
||||
where: { profileId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const disciplines =
|
||||
discipline_raw.length > 0
|
||||
? discipline_raw.slice(-2).map((item) => ({
|
||||
disciplineYear:
|
||||
Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ??
|
||||
null,
|
||||
disciplineDetail: item.detail ?? null,
|
||||
refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
disciplineYear: "-",
|
||||
disciplineDetail: "-",
|
||||
refNo: "-",
|
||||
},
|
||||
];
|
||||
|
||||
// const education_raw = await this.profileEducationRepo.find({
|
||||
// select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
|
||||
// where: { profileId: id },
|
||||
// // order: { lastUpdatedAt: "DESC" },
|
||||
// order: { level: "ASC" },
|
||||
// });
|
||||
// const educations =
|
||||
// education_raw.length > 0
|
||||
// ? education_raw.slice(-2).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 ?? "",
|
||||
// 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",
|
||||
// "posNo",
|
||||
// "positionType",
|
||||
// "positionLevel",
|
||||
// "positionSalaryAmount",
|
||||
// "commandNo",
|
||||
// "amount",
|
||||
// "remark",
|
||||
// ],
|
||||
// where: { profileId: id },
|
||||
// order: { order: "ASC" },
|
||||
// });
|
||||
const education_raw = await this.profileEducationRepo.find({
|
||||
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
|
||||
where: { profileId: id },
|
||||
// order: { lastUpdatedAt: "DESC" },
|
||||
order: { level: "ASC" },
|
||||
});
|
||||
const educations =
|
||||
education_raw.length > 0
|
||||
? education_raw.slice(-2).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 ?? "",
|
||||
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",
|
||||
"posNo",
|
||||
"positionType",
|
||||
"positionLevel",
|
||||
"positionSalaryAmount",
|
||||
"commandNo",
|
||||
"amount",
|
||||
"remark",
|
||||
],
|
||||
where: { profileId: id },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
|
||||
// const salarys =
|
||||
// salary_raw.length > 0
|
||||
// ? salary_raw.map((item) => ({
|
||||
// salaryDate: item.commandDateAffect
|
||||
// ? 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,
|
||||
// salary:
|
||||
// item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||
// rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
// refAll: item.remark ? Extension.ToThaiNumber(item.remark) : null,
|
||||
// positionLevel:
|
||||
// item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
// positionType: item.positionType ?? null,
|
||||
// positionAmount:
|
||||
// item.positionSalaryAmount == null
|
||||
// ? null
|
||||
// : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()),
|
||||
// fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
// ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// salaryDate: "-",
|
||||
// position: "-",
|
||||
// posNo: "-",
|
||||
// salary: "-",
|
||||
// rank: "-",
|
||||
// refAll: "-",
|
||||
// positionLevel: "-",
|
||||
// positionType: "-",
|
||||
// positionAmount: "-",
|
||||
// fullName: "-",
|
||||
// ocFullPath: "-",
|
||||
// },
|
||||
// ];
|
||||
const salarys =
|
||||
salary_raw.length > 0
|
||||
? salary_raw.map((item) => ({
|
||||
salaryDate: item.commandDateAffect
|
||||
? 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,
|
||||
salary:
|
||||
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||
rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
refAll: item.remark ? Extension.ToThaiNumber(item.remark) : null,
|
||||
positionLevel:
|
||||
item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
positionType: item.positionType ?? null,
|
||||
positionAmount:
|
||||
item.positionSalaryAmount == null
|
||||
? null
|
||||
: Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()),
|
||||
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
salaryDate: "-",
|
||||
position: "-",
|
||||
posNo: "-",
|
||||
salary: "-",
|
||||
rank: "-",
|
||||
refAll: "-",
|
||||
positionLevel: "-",
|
||||
positionType: "-",
|
||||
positionAmount: "-",
|
||||
fullName: "-",
|
||||
ocFullPath: "-",
|
||||
},
|
||||
];
|
||||
|
||||
// const insignia_raw = await this.profileInsigniaRepo.find({
|
||||
// relations: {
|
||||
// insignia: {
|
||||
// insigniaType: true,
|
||||
// },
|
||||
// },
|
||||
// where: { profileId: id },
|
||||
// order: { receiveDate: "ASC" },
|
||||
// });
|
||||
// const insignias =
|
||||
// insignia_raw.length > 0
|
||||
// ? insignia_raw.map((item) => ({
|
||||
// receiveDate: item.receiveDate
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate))
|
||||
// : "",
|
||||
// insigniaName: item.insignia.name,
|
||||
// insigniaShortName: item.insignia.shortName,
|
||||
// insigniaTypeName: item.insignia.insigniaType.name,
|
||||
// no: item.no ? Extension.ToThaiNumber(item.no) : "",
|
||||
// issue: item.issue ? item.issue : "",
|
||||
// volumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "",
|
||||
// volume: item.volume ? Extension.ToThaiNumber(item.volume) : "",
|
||||
// section: item.section ? Extension.ToThaiNumber(item.section) : "",
|
||||
// page: item.page ? Extension.ToThaiNumber(item.page) : "",
|
||||
// refCommandDate: item.refCommandDate
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate))
|
||||
// : "",
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// receiveDate: "-",
|
||||
// insigniaName: "-",
|
||||
// insigniaShortName: "-",
|
||||
// insigniaTypeName: "-",
|
||||
// no: "-",
|
||||
// issue: "-",
|
||||
// volumeNo: "-",
|
||||
// volume: "-",
|
||||
// section: "-",
|
||||
// page: "-",
|
||||
// refCommandDate: "-",
|
||||
// },
|
||||
// ];
|
||||
const insignia_raw = await this.profileInsigniaRepo.find({
|
||||
relations: {
|
||||
insignia: {
|
||||
insigniaType: true,
|
||||
},
|
||||
},
|
||||
where: { profileId: id },
|
||||
order: { receiveDate: "ASC" },
|
||||
});
|
||||
const insignias =
|
||||
insignia_raw.length > 0
|
||||
? insignia_raw.map((item) => ({
|
||||
receiveDate: item.receiveDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate))
|
||||
: "",
|
||||
insigniaName: item.insignia.name,
|
||||
insigniaShortName: item.insignia.shortName,
|
||||
insigniaTypeName: item.insignia.insigniaType.name,
|
||||
no: item.no ? Extension.ToThaiNumber(item.no) : "",
|
||||
issue: item.issue ? item.issue : "",
|
||||
volumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "",
|
||||
volume: item.volume ? Extension.ToThaiNumber(item.volume) : "",
|
||||
section: item.section ? Extension.ToThaiNumber(item.section) : "",
|
||||
page: item.page ? Extension.ToThaiNumber(item.page) : "",
|
||||
refCommandDate: item.refCommandDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate))
|
||||
: "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
receiveDate: "-",
|
||||
insigniaName: "-",
|
||||
insigniaShortName: "-",
|
||||
insigniaTypeName: "-",
|
||||
no: "-",
|
||||
issue: "-",
|
||||
volumeNo: "-",
|
||||
volume: "-",
|
||||
section: "-",
|
||||
page: "-",
|
||||
refCommandDate: "-",
|
||||
},
|
||||
];
|
||||
|
||||
// const leave_raw = await this.profileLeaveRepository.find({
|
||||
// relations: { leaveType: true },
|
||||
// where: { profileId: id },
|
||||
// order: { dateLeaveStart: "ASC" },
|
||||
// });
|
||||
// const leaves =
|
||||
// leave_raw.length > 0
|
||||
// ? leave_raw.map((item) => ({
|
||||
// leaveTypeName: item.leaveType.name,
|
||||
// dateLeaveStart: item.dateLeaveStart
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
||||
// : "",
|
||||
// leaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "",
|
||||
// }))
|
||||
// : [
|
||||
// {
|
||||
// leaveTypeName: "-",
|
||||
// dateLeaveStart: "-",
|
||||
// leaveDays: "-",
|
||||
// },
|
||||
// ];
|
||||
const leave_raw = await this.profileLeaveRepository.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId: id },
|
||||
order: { dateLeaveStart: "ASC" },
|
||||
});
|
||||
const leaves =
|
||||
leave_raw.length > 0
|
||||
? leave_raw.map((item) => ({
|
||||
leaveTypeName: item.leaveType.name,
|
||||
dateLeaveStart: item.dateLeaveStart
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
||||
: "",
|
||||
leaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
leaveTypeName: "-",
|
||||
dateLeaveStart: "-",
|
||||
leaveDays: "-",
|
||||
},
|
||||
];
|
||||
|
||||
// const data = {
|
||||
// fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
// prefix: profiles?.prefix != null ? profiles.prefix : "",
|
||||
// firstName: profiles?.firstName != null ? profiles.firstName : "",
|
||||
// lastName: profiles?.lastName != null ? profiles.lastName : "",
|
||||
// ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
// birthDate: profiles?.birthDate
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
|
||||
// : "",
|
||||
// retireDate:
|
||||
// profiles.dateRetireLaw != null
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
|
||||
// : "",
|
||||
// appointDate: profiles?.dateAppoint
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
|
||||
// : "",
|
||||
// citizenId:
|
||||
// profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
|
||||
// fatherFullName:
|
||||
// profileFamilyFather?.fatherPrefix ||
|
||||
// profileFamilyFather?.fatherFirstName ||
|
||||
// profileFamilyFather?.fatherLastName
|
||||
// ? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
||||
// : null,
|
||||
// motherFullName:
|
||||
// profileFamilyMother?.motherPrefix ||
|
||||
// profileFamilyMother?.motherFirstName ||
|
||||
// profileFamilyMother?.motherLastName
|
||||
// ? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
||||
// : null,
|
||||
// coupleFullName:
|
||||
// profileFamilyCouple?.couplePrefix ||
|
||||
// profileFamilyCouple?.coupleFirstName ||
|
||||
// profileFamilyCouple?.coupleLastNameOld
|
||||
// ? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
|
||||
// : null,
|
||||
// coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
|
||||
// currentAddress:
|
||||
// profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
|
||||
// currentSubDistrict:
|
||||
// profiles.currentSubDistrict != null
|
||||
// ? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
|
||||
// : "",
|
||||
// currentDistrict:
|
||||
// profiles.currentDistrict != null
|
||||
// ? Extension.ToThaiNumber(profiles.currentDistrict.name)
|
||||
// : "",
|
||||
// currentProvince:
|
||||
// profiles.currentProvince != null
|
||||
// ? Extension.ToThaiNumber(profiles.currentProvince.name)
|
||||
// : "",
|
||||
// telephone:
|
||||
// profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
|
||||
// url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`,
|
||||
// url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
||||
// yearUpload1: profiles.profileAvatars[0]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
|
||||
// : null,
|
||||
// url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
||||
// yearUpload2: profiles.profileAvatars[1]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt))
|
||||
// : null,
|
||||
// url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
||||
// yearUpload3: profiles.profileAvatars[2]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt))
|
||||
// : null,
|
||||
// url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
||||
// yearUpload4: profiles.profileAvatars[3]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt))
|
||||
// : null,
|
||||
// url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
||||
// yearUpload5: profiles.profileAvatars[4]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt))
|
||||
// : null,
|
||||
// url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
||||
// yearUpload6: profiles.profileAvatars[5]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt))
|
||||
// : null,
|
||||
// url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
||||
// yearUpload7: profiles.profileAvatars[6]
|
||||
// ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt))
|
||||
// : null,
|
||||
// insignias,
|
||||
// leaves,
|
||||
// certs,
|
||||
// trainings,
|
||||
// disciplines,
|
||||
// educations,
|
||||
// salarys,
|
||||
// };
|
||||
const data = {
|
||||
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
prefix: profiles?.prefix != null ? profiles.prefix : "",
|
||||
firstName: profiles?.firstName != null ? profiles.firstName : "",
|
||||
lastName: profiles?.lastName != null ? profiles.lastName : "",
|
||||
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
birthDate: profiles?.birthDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
|
||||
: "",
|
||||
retireDate:
|
||||
profiles.dateRetireLaw != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
|
||||
: "",
|
||||
appointDate: profiles?.dateAppoint
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
|
||||
: "",
|
||||
citizenId:
|
||||
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
|
||||
fatherFullName:
|
||||
profileFamilyFather?.fatherPrefix ||
|
||||
profileFamilyFather?.fatherFirstName ||
|
||||
profileFamilyFather?.fatherLastName
|
||||
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
||||
: null,
|
||||
motherFullName:
|
||||
profileFamilyMother?.motherPrefix ||
|
||||
profileFamilyMother?.motherFirstName ||
|
||||
profileFamilyMother?.motherLastName
|
||||
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
||||
: null,
|
||||
coupleFullName:
|
||||
profileFamilyCouple?.couplePrefix ||
|
||||
profileFamilyCouple?.coupleFirstName ||
|
||||
profileFamilyCouple?.coupleLastNameOld
|
||||
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
|
||||
: null,
|
||||
coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
|
||||
currentAddress:
|
||||
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
|
||||
currentSubDistrict:
|
||||
profiles.currentSubDistrict != null
|
||||
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
|
||||
: "",
|
||||
currentDistrict:
|
||||
profiles.currentDistrict != null
|
||||
? Extension.ToThaiNumber(profiles.currentDistrict.name)
|
||||
: "",
|
||||
currentProvince:
|
||||
profiles.currentProvince != null
|
||||
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
||||
: "",
|
||||
telephone:
|
||||
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
|
||||
url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`,
|
||||
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
||||
yearUpload1: profiles.profileAvatars[0]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
|
||||
: null,
|
||||
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
||||
yearUpload2: profiles.profileAvatars[1]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt))
|
||||
: null,
|
||||
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
||||
yearUpload3: profiles.profileAvatars[2]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt))
|
||||
: null,
|
||||
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
||||
yearUpload4: profiles.profileAvatars[3]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt))
|
||||
: null,
|
||||
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
||||
yearUpload5: profiles.profileAvatars[4]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt))
|
||||
: null,
|
||||
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
||||
yearUpload6: profiles.profileAvatars[5]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt))
|
||||
: null,
|
||||
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
||||
yearUpload7: profiles.profileAvatars[6]
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt))
|
||||
: null,
|
||||
insignias,
|
||||
leaves,
|
||||
certs,
|
||||
trainings,
|
||||
disciplines,
|
||||
educations,
|
||||
salarys,
|
||||
};
|
||||
|
||||
// return new HttpSuccess({
|
||||
// template: "kk1",
|
||||
// reportName: "docx-report",
|
||||
// data: data,
|
||||
// });
|
||||
// }
|
||||
return new HttpSuccess({
|
||||
template: "kk1",
|
||||
reportName: "docx-report",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* รายงาน ก.ก.1 (ข้าราชการ) ใหม่
|
||||
|
|
@ -874,8 +874,8 @@ export class ProfileController extends Controller {
|
|||
*
|
||||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kk1/{id}")
|
||||
public async getKk1(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
@Get("kk1new/{id}")
|
||||
public async getKk1new(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.findOne({
|
||||
relations: ["currentSubDistrict", "currentDistrict", "currentProvince","registrationSubDistrict", "registrationDistrict", "registrationProvince", "profileAvatars"],
|
||||
order: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue