no message
This commit is contained in:
parent
71cfc78c6e
commit
7297f2bbc3
3 changed files with 318 additions and 235 deletions
|
|
@ -128,19 +128,19 @@ export class ProfileController extends Controller {
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
date: "DESC"
|
date: "DESC",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
let ImgUrl: any
|
let ImgUrl: any;
|
||||||
if(profile?.avatar != null && profile?.avatarName != null) {
|
if (profile?.avatar != null && profile?.avatarName != null) {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
|
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
|
||||||
.then(async (x) => {
|
.then(async (x) => {
|
||||||
ImgUrl = x.downloadUrl
|
ImgUrl = x.downloadUrl;
|
||||||
})
|
})
|
||||||
.catch();
|
.catch();
|
||||||
}
|
}
|
||||||
const province = await this.provinceRepository.findOneBy({
|
const province = await this.provinceRepository.findOneBy({
|
||||||
id: profile.registrationProvinceId,
|
id: profile.registrationProvinceId,
|
||||||
|
|
@ -249,7 +249,9 @@ export class ProfileController extends Controller {
|
||||||
: "-",
|
: "-",
|
||||||
PositionName: profile.position != null ? profile.position : "-",
|
PositionName: profile.position != null ? profile.position : "-",
|
||||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
ImgUrl: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`
|
ImgUrl: ImgUrl
|
||||||
|
? ImgUrl
|
||||||
|
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
|
|
@ -282,14 +284,14 @@ export class ProfileController extends Controller {
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
let ImgUrl: any
|
let ImgUrl: any;
|
||||||
if(profiles?.avatar != null && profiles?.avatarName != null) {
|
if (profiles?.avatar != null && profiles?.avatarName != null) {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
|
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
|
||||||
.then(async (x) => {
|
.then(async (x) => {
|
||||||
ImgUrl = x.downloadUrl
|
ImgUrl = x.downloadUrl;
|
||||||
})
|
})
|
||||||
.catch();
|
.catch();
|
||||||
}
|
}
|
||||||
const profileOc = await this.profileRepo.findOne({
|
const profileOc = await this.profileRepo.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
|
|
@ -450,107 +452,124 @@ export class ProfileController extends Controller {
|
||||||
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
||||||
: "",
|
: "",
|
||||||
// AvatarId: profiles?.avatar ?? null,
|
// AvatarId: profiles?.avatar ?? null,
|
||||||
ImgUrl: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`
|
ImgUrl: ImgUrl
|
||||||
|
? ImgUrl
|
||||||
|
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const certs = await this.certificateRepository.find({
|
const certs = await this.certificateRepository.find({
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
||||||
});
|
});
|
||||||
const Cert = certs.length > 0
|
const Cert =
|
||||||
? certs.map((item) => ({
|
certs.length > 0
|
||||||
CertificateType: item.certificateType ?? null,
|
? certs.map((item) => ({
|
||||||
Issuer: item.issuer ?? null,
|
CertificateType: item.certificateType ?? null,
|
||||||
CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
|
Issuer: item.issuer ?? null,
|
||||||
IssueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null,
|
CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
|
||||||
}))
|
IssueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null,
|
||||||
:[{
|
}))
|
||||||
CertificateType: "-",
|
: [
|
||||||
Issuer: "-",
|
{
|
||||||
CertificateNo: "-",
|
CertificateType: "-",
|
||||||
IssueDate: "-"
|
Issuer: "-",
|
||||||
}];
|
CertificateNo: "-",
|
||||||
|
IssueDate: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
const trainings = await this.trainingRepository.find({
|
const trainings = await this.trainingRepository.find({
|
||||||
select: ["startDate", "endDate", "place", "department", "name"],
|
select: ["startDate", "endDate", "place", "department", "name"],
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
});
|
});
|
||||||
const Training = trainings.length > 0
|
const Training =
|
||||||
? trainings.map((item) => ({
|
trainings.length > 0
|
||||||
Institute: item.department ?? "",
|
? trainings.map((item) => ({
|
||||||
Start:
|
Institute: item.department ?? "",
|
||||||
item.startDate == null
|
Start:
|
||||||
? ""
|
item.startDate == null
|
||||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)),
|
? ""
|
||||||
End:
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)),
|
||||||
item.endDate == null ? "" : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
|
End:
|
||||||
Date:
|
item.endDate == null
|
||||||
item.startDate && item.endDate
|
? ""
|
||||||
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
|
||||||
: "",
|
Date:
|
||||||
Level: "",
|
item.startDate && item.endDate
|
||||||
Degree: item.name,
|
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
||||||
Field: "",
|
: "",
|
||||||
}))
|
Level: "",
|
||||||
: [{
|
Degree: item.name,
|
||||||
Institute: "-",
|
Field: "",
|
||||||
Start: "-",
|
}))
|
||||||
End: "-",
|
: [
|
||||||
Date: "-",
|
{
|
||||||
Level: "-",
|
Institute: "-",
|
||||||
Degree: "-",
|
Start: "-",
|
||||||
Field: "-",
|
End: "-",
|
||||||
}];
|
Date: "-",
|
||||||
|
Level: "-",
|
||||||
|
Degree: "-",
|
||||||
|
Field: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const disciplines = await this.disciplineRepository.find({
|
const disciplines = await this.disciplineRepository.find({
|
||||||
select: ["refCommandDate", "refCommandNo", "detail"],
|
select: ["refCommandDate", "refCommandNo", "detail"],
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
});
|
});
|
||||||
const Discipline = disciplines.length > 0
|
const Discipline =
|
||||||
? disciplines.map((item) => ({
|
disciplines.length > 0
|
||||||
DisciplineYear:
|
? disciplines.map((item) => ({
|
||||||
Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? null,
|
DisciplineYear:
|
||||||
DisciplineDetail: item.detail ?? null,
|
Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ??
|
||||||
RefNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
|
null,
|
||||||
}))
|
DisciplineDetail: item.detail ?? null,
|
||||||
: [{
|
RefNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
|
||||||
DisciplineYear: "-",
|
}))
|
||||||
DisciplineDetail: "-",
|
: [
|
||||||
RefNo: "-",
|
{
|
||||||
}];
|
DisciplineYear: "-",
|
||||||
|
DisciplineDetail: "-",
|
||||||
|
RefNo: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const educations = await this.educationRepository.find({
|
const educations = await this.educationRepository.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" },
|
||||||
});
|
});
|
||||||
const Education = educations.length > 0
|
const Education =
|
||||||
? educations.map((item) => ({
|
educations.length > 0
|
||||||
Institute: item.institute,
|
? educations.map((item) => ({
|
||||||
Start:
|
Institute: item.institute,
|
||||||
item.startDate == null
|
Start:
|
||||||
? ""
|
item.startDate == null
|
||||||
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
|
? ""
|
||||||
End:
|
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
|
||||||
item.endDate == null
|
End:
|
||||||
? ""
|
item.endDate == null
|
||||||
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
? ""
|
||||||
Date:
|
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
||||||
item.startDate && item.endDate
|
Date:
|
||||||
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
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 : ""}` : "",
|
Level: item.educationLevel ?? "",
|
||||||
Field: item.field ?? "-",
|
Degree: item.degree ? `${item.degree} ${item.field ? item.field : ""}` : "",
|
||||||
}))
|
Field: item.field ?? "-",
|
||||||
: [{
|
}))
|
||||||
Institute: "-",
|
: [
|
||||||
Start: "-",
|
{
|
||||||
End: "-",
|
Institute: "-",
|
||||||
Date: "-",
|
Start: "-",
|
||||||
Level: "-",
|
End: "-",
|
||||||
Degree: "-",
|
Date: "-",
|
||||||
Field: "-",
|
Level: "-",
|
||||||
}];
|
Degree: "-",
|
||||||
|
Field: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
const salarys = await this.salaryRepository.find({
|
const salarys = await this.salaryRepository.find({
|
||||||
select: [
|
select: [
|
||||||
"date",
|
"date",
|
||||||
|
|
@ -564,39 +583,46 @@ export class ProfileController extends Controller {
|
||||||
"templateDoc",
|
"templateDoc",
|
||||||
],
|
],
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
order: { order: "ASC" }
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const Salary = salarys.length > 0
|
const Salary =
|
||||||
? salarys.map((item) => ({
|
salarys.length > 0
|
||||||
SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date)) : null,
|
? salarys.map((item) => ({
|
||||||
Position: item.position != null ? Extension.ToThaiNumber(item.position) : null,
|
SalaryDate: item.date
|
||||||
PosNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null,
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date))
|
||||||
Salary: item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
: null,
|
||||||
Rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
Position: item.position != null ? Extension.ToThaiNumber(item.position) : null,
|
||||||
RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null,
|
PosNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null,
|
||||||
PositionLevel: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
Salary:
|
||||||
PositionType: item.positionType ?? null,
|
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||||
PositionAmount:
|
Rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||||
item.positionSalaryAmount == null
|
RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null,
|
||||||
? null
|
PositionLevel:
|
||||||
: Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()),
|
item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||||
FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
PositionType: item.positionType ?? null,
|
||||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
PositionAmount:
|
||||||
}))
|
item.positionSalaryAmount == null
|
||||||
: [{
|
? null
|
||||||
SalaryDate: "-",
|
: Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()),
|
||||||
Position: "-",
|
FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||||
PosNo: "-",
|
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
Salary: "-",
|
}))
|
||||||
Rank: "-",
|
: [
|
||||||
RefAll: "-",
|
{
|
||||||
PositionLevel: "-",
|
SalaryDate: "-",
|
||||||
PositionType: "-",
|
Position: "-",
|
||||||
PositionAmount: "-",
|
PosNo: "-",
|
||||||
FullName: "-",
|
Salary: "-",
|
||||||
OcFullPath: "-",
|
Rank: "-",
|
||||||
}];
|
RefAll: "-",
|
||||||
|
PositionLevel: "-",
|
||||||
|
PositionType: "-",
|
||||||
|
PositionAmount: "-",
|
||||||
|
FullName: "-",
|
||||||
|
OcFullPath: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const insignias = await this.profileInsigniaRepo.find({
|
const insignias = await this.profileInsigniaRepo.find({
|
||||||
relations: {
|
relations: {
|
||||||
|
|
@ -607,56 +633,62 @@ export class ProfileController extends Controller {
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
order: { receiveDate: "ASC" },
|
order: { receiveDate: "ASC" },
|
||||||
});
|
});
|
||||||
const Insignia = insignias.length > 0
|
const Insignia =
|
||||||
? insignias.map((item) => ({
|
insignias.length > 0
|
||||||
ReceiveDate: item.receiveDate
|
? insignias.map((item) => ({
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate))
|
ReceiveDate: item.receiveDate
|
||||||
: "",
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate))
|
||||||
InsigniaName: item.insignia.name,
|
: "",
|
||||||
InsigniaShortName: item.insignia.shortName,
|
InsigniaName: item.insignia.name,
|
||||||
InsigniaTypeName: item.insignia.insigniaType.name,
|
InsigniaShortName: item.insignia.shortName,
|
||||||
No: item.no ? Extension.ToThaiNumber(item.no) : "",
|
InsigniaTypeName: item.insignia.insigniaType.name,
|
||||||
Issue: item.issue ? item.issue : "",
|
No: item.no ? Extension.ToThaiNumber(item.no) : "",
|
||||||
VolumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "",
|
Issue: item.issue ? item.issue : "",
|
||||||
Volume: item.volume ? Extension.ToThaiNumber(item.volume) : "",
|
VolumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "",
|
||||||
Section: item.section ? Extension.ToThaiNumber(item.section) : "",
|
Volume: item.volume ? Extension.ToThaiNumber(item.volume) : "",
|
||||||
Page: item.page ? Extension.ToThaiNumber(item.page) : "",
|
Section: item.section ? Extension.ToThaiNumber(item.section) : "",
|
||||||
RefCommandDate: item.refCommandDate
|
Page: item.page ? Extension.ToThaiNumber(item.page) : "",
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate))
|
RefCommandDate: item.refCommandDate
|
||||||
: "",
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate))
|
||||||
}))
|
: "",
|
||||||
: [{
|
}))
|
||||||
ReceiveDate: "-",
|
: [
|
||||||
InsigniaName: "-",
|
{
|
||||||
InsigniaShortName: "-",
|
ReceiveDate: "-",
|
||||||
InsigniaTypeName: "-",
|
InsigniaName: "-",
|
||||||
No: "-",
|
InsigniaShortName: "-",
|
||||||
Issue: "-",
|
InsigniaTypeName: "-",
|
||||||
VolumeNo: "-",
|
No: "-",
|
||||||
Volume: "-",
|
Issue: "-",
|
||||||
Section: "-",
|
VolumeNo: "-",
|
||||||
Page: "-",
|
Volume: "-",
|
||||||
RefCommandDate: "-",
|
Section: "-",
|
||||||
}];
|
Page: "-",
|
||||||
|
RefCommandDate: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const leaves = await this.profileLeaveRepository.find({
|
const leaves = await this.profileLeaveRepository.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
order: { dateLeaveStart: "ASC" },
|
order: { dateLeaveStart: "ASC" },
|
||||||
});
|
});
|
||||||
const Leave = leaves.length > 0
|
const Leave =
|
||||||
? leaves.map((item) => ({
|
leaves.length > 0
|
||||||
LeaveTypeName: item.leaveType.name,
|
? leaves.map((item) => ({
|
||||||
DateLeaveStart: item.dateLeaveStart
|
LeaveTypeName: item.leaveType.name,
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
DateLeaveStart: item.dateLeaveStart
|
||||||
: "",
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
||||||
LeaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "",
|
: "",
|
||||||
}))
|
LeaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "",
|
||||||
: [{
|
}))
|
||||||
LeaveTypeName: "-",
|
: [
|
||||||
DateLeaveStart: "-",
|
{
|
||||||
LeaveDays: "-",
|
LeaveTypeName: "-",
|
||||||
}];
|
DateLeaveStart: "-",
|
||||||
|
LeaveDays: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
Profile: [Profile],
|
Profile: [Profile],
|
||||||
|
|
@ -2604,7 +2636,7 @@ export class ProfileController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async getProfile(@Request() req: RequestWithUser, @Path() id: string) {
|
async getProfile(@Request() req: RequestWithUser, @Path() id: string) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||||
const profile = await this.profileRepo.findOne({
|
let profile: any = await this.profileRepo.findOne({
|
||||||
relations: {
|
relations: {
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
posType: true,
|
posType: true,
|
||||||
|
|
@ -2613,7 +2645,7 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
profile.profileType = "OFFICER";
|
||||||
return new HttpSuccess(profile);
|
return new HttpSuccess(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3187,21 +3219,30 @@ export class ProfileController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("keycloak/position")
|
@Get("keycloak/position")
|
||||||
async getProfileByKeycloak(@Request() request: { user: Record<string, any> } , @Query("revisionId") revisionId?: string,) {
|
async getProfileByKeycloak(
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
@Query("revisionId") revisionId?: string,
|
||||||
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalary"],
|
relations: [
|
||||||
|
"posLevel",
|
||||||
|
"posType",
|
||||||
|
"current_holders",
|
||||||
|
"current_holders.orgRoot",
|
||||||
|
"profileSalary",
|
||||||
|
],
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
order: "DESC",
|
order: "DESC",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
let orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.orgRevisionIsDraft = false")
|
.where("orgRevision.orgRevisionIsDraft = false")
|
||||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||||
|
|
@ -3211,7 +3252,7 @@ export class ProfileController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revisionId) {
|
if (revisionId) {
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.id = :revisionId", { revisionId })
|
.where("orgRevision.id = :revisionId", { revisionId })
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
@ -3314,9 +3355,7 @@ export class ProfileController extends Controller {
|
||||||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||||
node: null,
|
node: null,
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
salary: profile && profile.profileSalary.length > 0
|
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||||
? profile.profileSalary[0].amount
|
|
||||||
: null
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
|
|
@ -3357,9 +3396,9 @@ export class ProfileController extends Controller {
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo.findOne({
|
const orgRevisionPublish = await this.orgRevisionRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionIsDraft: false,
|
orgRevisionIsDraft: false,
|
||||||
orgRevisionIsCurrent: true
|
orgRevisionIsCurrent: true,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
if (!orgRevisionPublish) {
|
if (!orgRevisionPublish) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||||
}
|
}
|
||||||
|
|
@ -3421,10 +3460,18 @@ export class ProfileController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const fullNameParts = [
|
const fullNameParts = [
|
||||||
posMaster_ == null || posMaster_.orgChild4 == null ? null : posMaster_.orgChild4.orgChild4Name,
|
posMaster_ == null || posMaster_.orgChild4 == null
|
||||||
posMaster_ == null || posMaster_.orgChild3 == null ? null : posMaster_.orgChild3.orgChild3Name,
|
? null
|
||||||
posMaster_ == null || posMaster_.orgChild2 == null ? null : posMaster_.orgChild2.orgChild2Name,
|
: posMaster_.orgChild4.orgChild4Name,
|
||||||
posMaster_ == null || posMaster_.orgChild1 == null ? null : posMaster_.orgChild1.orgChild1Name,
|
posMaster_ == null || posMaster_.orgChild3 == null
|
||||||
|
? null
|
||||||
|
: posMaster_.orgChild3.orgChild3Name,
|
||||||
|
posMaster_ == null || posMaster_.orgChild2 == null
|
||||||
|
? null
|
||||||
|
: posMaster_.orgChild2.orgChild2Name,
|
||||||
|
posMaster_ == null || posMaster_.orgChild1 == null
|
||||||
|
? null
|
||||||
|
: posMaster_.orgChild1.orgChild1Name,
|
||||||
posMaster_ == null || posMaster_.orgRoot == null ? null : posMaster_.orgRoot.orgRootName,
|
posMaster_ == null || posMaster_.orgRoot == null ? null : posMaster_.orgRoot.orgRootName,
|
||||||
];
|
];
|
||||||
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
||||||
|
|
@ -3539,7 +3586,7 @@ export class ProfileController extends Controller {
|
||||||
let commanderAbovePosition_: any = {};
|
let commanderAbovePosition_: any = {};
|
||||||
let commanderAboveRootName_: any = {};
|
let commanderAboveRootName_: any = {};
|
||||||
let commanderAboveOrg_: any;
|
let commanderAboveOrg_: any;
|
||||||
let dataCommander: any
|
let dataCommander: any;
|
||||||
|
|
||||||
commanderFullname_ =
|
commanderFullname_ =
|
||||||
(findCmd?.current_holder?.prefix ?? "") +
|
(findCmd?.current_holder?.prefix ?? "") +
|
||||||
|
|
@ -3555,14 +3602,14 @@ export class ProfileController extends Controller {
|
||||||
commanderAbovePosition_ = findOSAB?.current_holder?.position ?? "";
|
commanderAbovePosition_ = findOSAB?.current_holder?.position ?? "";
|
||||||
|
|
||||||
if (findCmd?.current_holderId == profile?.id) {
|
if (findCmd?.current_holderId == profile?.id) {
|
||||||
commandProfileId = findOSAB?.current_holderId
|
commandProfileId = findOSAB?.current_holderId;
|
||||||
commanderFullname_ =
|
commanderFullname_ =
|
||||||
(findOSAB?.current_holder?.prefix ?? "") +
|
(findOSAB?.current_holder?.prefix ?? "") +
|
||||||
(findOSAB?.current_holder?.firstName ?? "") +
|
(findOSAB?.current_holder?.firstName ?? "") +
|
||||||
(findOSAB?.current_holder?.firstName ? " " : "") +
|
(findOSAB?.current_holder?.firstName ? " " : "") +
|
||||||
(findOSAB?.current_holder?.lastName ?? "");
|
(findOSAB?.current_holder?.lastName ?? "");
|
||||||
commanderPosition_ = findOSAB?.current_holder?.position ?? "";
|
commanderPosition_ = findOSAB?.current_holder?.position ?? "";
|
||||||
commandAboveProfileId = findTSAB?.current_holderId
|
commandAboveProfileId = findTSAB?.current_holderId;
|
||||||
commanderAboveFullname_ =
|
commanderAboveFullname_ =
|
||||||
(findTSAB?.current_holder?.prefix ?? "") +
|
(findTSAB?.current_holder?.prefix ?? "") +
|
||||||
(findTSAB?.current_holder?.firstName ?? "") +
|
(findTSAB?.current_holder?.firstName ?? "") +
|
||||||
|
|
@ -3575,10 +3622,9 @@ export class ProfileController extends Controller {
|
||||||
commanderAboveFullname: commanderAboveFullname_,
|
commanderAboveFullname: commanderAboveFullname_,
|
||||||
commanderAbovePosition: commanderAbovePosition_,
|
commanderAbovePosition: commanderAbovePosition_,
|
||||||
};
|
};
|
||||||
}
|
} else {
|
||||||
else {
|
commandProfileId = findCmd?.current_holderId;
|
||||||
commandProfileId = findCmd?.current_holderId
|
commandAboveProfileId = findOSAB?.current_holderId;
|
||||||
commandAboveProfileId = findOSAB?.current_holderId
|
|
||||||
dataCommander = {
|
dataCommander = {
|
||||||
commanderFullname: commanderFullname_,
|
commanderFullname: commanderFullname_,
|
||||||
commanderPosition: commanderPosition_,
|
commanderPosition: commanderPosition_,
|
||||||
|
|
@ -3594,9 +3640,11 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
commanderRootName_ =
|
commanderRootName_ =
|
||||||
commandProfile?.current_holders == null ||
|
commandProfile?.current_holders == null ||
|
||||||
commandProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
commandProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||||
|
?.orgRoot == null
|
||||||
? null
|
? null
|
||||||
: commandProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
: commandProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||||
|
?.orgRoot;
|
||||||
//find สังกัดผู้บังคับบัญชา
|
//find สังกัดผู้บังคับบัญชา
|
||||||
const commanderPosMaster_ = await this.posMasterRepo.findOne({
|
const commanderPosMaster_ = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -3613,13 +3661,25 @@ export class ProfileController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const commanderFullNameParts = [
|
const commanderFullNameParts = [
|
||||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild4 == null ? null : commanderPosMaster_.orgChild4.orgChild4Name,
|
commanderPosMaster_ == null || commanderPosMaster_.orgChild4 == null
|
||||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild3 == null ? null : commanderPosMaster_.orgChild3.orgChild3Name,
|
? null
|
||||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild2 == null ? null : commanderPosMaster_.orgChild2.orgChild2Name,
|
: commanderPosMaster_.orgChild4.orgChild4Name,
|
||||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild1 == null ? null : commanderPosMaster_.orgChild1.orgChild1Name,
|
commanderPosMaster_ == null || commanderPosMaster_.orgChild3 == null
|
||||||
commanderPosMaster_ == null || commanderPosMaster_.orgRoot == null ? null : commanderPosMaster_.orgRoot.orgRootName,
|
? null
|
||||||
|
: commanderPosMaster_.orgChild3.orgChild3Name,
|
||||||
|
commanderPosMaster_ == null || commanderPosMaster_.orgChild2 == null
|
||||||
|
? null
|
||||||
|
: commanderPosMaster_.orgChild2.orgChild2Name,
|
||||||
|
commanderPosMaster_ == null || commanderPosMaster_.orgChild1 == null
|
||||||
|
? null
|
||||||
|
: commanderPosMaster_.orgChild1.orgChild1Name,
|
||||||
|
commanderPosMaster_ == null || commanderPosMaster_.orgRoot == null
|
||||||
|
? null
|
||||||
|
: commanderPosMaster_.orgRoot.orgRootName,
|
||||||
];
|
];
|
||||||
commanderOrg_ = commanderFullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
commanderOrg_ = commanderFullNameParts
|
||||||
|
.filter((part) => part !== undefined && part !== null)
|
||||||
|
.join("/");
|
||||||
|
|
||||||
const commandAboveProfile = await this.profileRepo.findOne({
|
const commandAboveProfile = await this.profileRepo.findOne({
|
||||||
where: { id: String(commandAboveProfileId) },
|
where: { id: String(commandAboveProfileId) },
|
||||||
|
|
@ -3628,9 +3688,11 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
commanderAboveRootName_ =
|
commanderAboveRootName_ =
|
||||||
commandAboveProfile?.current_holders == null ||
|
commandAboveProfile?.current_holders == null ||
|
||||||
commandAboveProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
commandAboveProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||||
? null
|
?.orgRoot == null
|
||||||
: commandAboveProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
? null
|
||||||
|
: commandAboveProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||||
|
?.orgRoot;
|
||||||
//find สังกัดผู้บังคับบัญชาเหนือไป1ขั้น
|
//find สังกัดผู้บังคับบัญชาเหนือไป1ขั้น
|
||||||
const commanderAbovePosMaster_ = await this.posMasterRepo.findOne({
|
const commanderAbovePosMaster_ = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -3647,13 +3709,25 @@ export class ProfileController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const commanderAboveFullNameParts = [
|
const commanderAboveFullNameParts = [
|
||||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild4 == null ? null : commanderAbovePosMaster_.orgChild4.orgChild4Name,
|
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild4 == null
|
||||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild3 == null ? null : commanderAbovePosMaster_.orgChild3.orgChild3Name,
|
? null
|
||||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild2 == null ? null : commanderAbovePosMaster_.orgChild2.orgChild2Name,
|
: commanderAbovePosMaster_.orgChild4.orgChild4Name,
|
||||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild1 == null ? null : commanderAbovePosMaster_.orgChild1.orgChild1Name,
|
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild3 == null
|
||||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgRoot == null ? null : commanderAbovePosMaster_.orgRoot.orgRootName,
|
? null
|
||||||
|
: commanderAbovePosMaster_.orgChild3.orgChild3Name,
|
||||||
|
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild2 == null
|
||||||
|
? null
|
||||||
|
: commanderAbovePosMaster_.orgChild2.orgChild2Name,
|
||||||
|
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild1 == null
|
||||||
|
? null
|
||||||
|
: commanderAbovePosMaster_.orgChild1.orgChild1Name,
|
||||||
|
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgRoot == null
|
||||||
|
? null
|
||||||
|
: commanderAbovePosMaster_.orgRoot.orgRootName,
|
||||||
];
|
];
|
||||||
commanderAboveOrg_ = commanderAboveFullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
commanderAboveOrg_ = commanderAboveFullNameParts
|
||||||
|
.filter((part) => part !== undefined && part !== null)
|
||||||
|
.join("/");
|
||||||
|
|
||||||
const _profile: any = {
|
const _profile: any = {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
|
|
@ -3707,21 +3781,29 @@ export class ProfileController extends Controller {
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
org: org ? org : null,
|
org: org ? org : null,
|
||||||
// commander: dataCommander,
|
// commander: dataCommander,
|
||||||
commanderFullname: dataCommander && dataCommander.commanderFullname
|
commanderFullname:
|
||||||
? dataCommander.commanderFullname : null,
|
dataCommander && dataCommander.commanderFullname ? dataCommander.commanderFullname : null,
|
||||||
commanderPosition: dataCommander && dataCommander.commanderPosition
|
commanderPosition:
|
||||||
? dataCommander.commanderPosition : null,
|
dataCommander && dataCommander.commanderPosition ? dataCommander.commanderPosition : null,
|
||||||
commanderRootName: commanderRootName_ && commanderRootName_.orgRootName
|
commanderRootName:
|
||||||
? commanderRootName_.orgRootName : null,
|
commanderRootName_ && commanderRootName_.orgRootName
|
||||||
|
? commanderRootName_.orgRootName
|
||||||
|
: null,
|
||||||
commanderOrg: commanderOrg_ ? commanderOrg_ : null,
|
commanderOrg: commanderOrg_ ? commanderOrg_ : null,
|
||||||
commanderAboveFullname: dataCommander && dataCommander.commanderAboveFullname
|
commanderAboveFullname:
|
||||||
? dataCommander.commanderAboveFullname : null,
|
dataCommander && dataCommander.commanderAboveFullname
|
||||||
commanderAbovePosition: dataCommander && dataCommander.commanderAbovePosition
|
? dataCommander.commanderAboveFullname
|
||||||
? dataCommander.commanderAbovePosition : null,
|
: null,
|
||||||
commanderAboveRootName: commanderAboveRootName_ && commanderAboveRootName_.orgRootName
|
commanderAbovePosition:
|
||||||
? commanderAboveRootName_.orgRootName : null,
|
dataCommander && dataCommander.commanderAbovePosition
|
||||||
|
? dataCommander.commanderAbovePosition
|
||||||
|
: null,
|
||||||
|
commanderAboveRootName:
|
||||||
|
commanderAboveRootName_ && commanderAboveRootName_.orgRootName
|
||||||
|
? commanderAboveRootName_.orgRootName
|
||||||
|
: null,
|
||||||
commanderAboveOrg: commanderAboveOrg_ ? commanderAboveOrg_ : null,
|
commanderAboveOrg: commanderAboveOrg_ ? commanderAboveOrg_ : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
_profile.node = 4;
|
_profile.node = 4;
|
||||||
|
|
|
||||||
|
|
@ -1204,7 +1204,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile: any = await this.profileRepo.findOne({
|
||||||
relations: {
|
relations: {
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
posType: true,
|
posType: true,
|
||||||
|
|
@ -1216,6 +1216,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
profile.profileType = "EMPLOYEE";
|
||||||
|
|
||||||
return new HttpSuccess(profile);
|
return new HttpSuccess(profile);
|
||||||
}
|
}
|
||||||
|
|
@ -1795,7 +1796,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
let orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.orgRevisionIsDraft = false")
|
.where("orgRevision.orgRevisionIsDraft = false")
|
||||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||||
|
|
@ -1805,7 +1806,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revisionId) {
|
if (revisionId) {
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.id = :revisionId", { revisionId })
|
.where("orgRevision.id = :revisionId", { revisionId })
|
||||||
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
||||||
|
|
|
||||||
|
|
@ -1558,7 +1558,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
let orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.orgRevisionIsDraft = false")
|
.where("orgRevision.orgRevisionIsDraft = false")
|
||||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||||
|
|
@ -1568,7 +1568,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revisionId) {
|
if (revisionId) {
|
||||||
const orgRevisionPublish = await this.orgRevisionRepo
|
orgRevisionPublish = await this.orgRevisionRepo
|
||||||
.createQueryBuilder("orgRevision")
|
.createQueryBuilder("orgRevision")
|
||||||
.where("orgRevision.id = :revisionId", { revisionId })
|
.where("orgRevision.id = :revisionId", { revisionId })
|
||||||
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue