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 },
|
||||
order: {
|
||||
profileSalary: {
|
||||
date: "DESC"
|
||||
}
|
||||
}
|
||||
date: "DESC",
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
let ImgUrl: any
|
||||
if(profile?.avatar != null && profile?.avatarName != null) {
|
||||
let ImgUrl: any;
|
||||
if (profile?.avatar != null && profile?.avatarName != null) {
|
||||
await new CallAPI()
|
||||
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
|
||||
.then(async (x) => {
|
||||
ImgUrl = x.downloadUrl
|
||||
})
|
||||
.catch();
|
||||
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
|
||||
.then(async (x) => {
|
||||
ImgUrl = x.downloadUrl;
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
const province = await this.provinceRepository.findOneBy({
|
||||
id: profile.registrationProvinceId,
|
||||
|
|
@ -249,7 +249,9 @@ export class ProfileController extends Controller {
|
|||
: "-",
|
||||
PositionName: profile.position != null ? profile.position : "-",
|
||||
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);
|
||||
|
|
@ -282,14 +284,14 @@ export class ProfileController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
let ImgUrl: any
|
||||
if(profiles?.avatar != null && profiles?.avatarName != null) {
|
||||
let ImgUrl: any;
|
||||
if (profiles?.avatar != null && profiles?.avatarName != null) {
|
||||
await new CallAPI()
|
||||
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
|
||||
.then(async (x) => {
|
||||
ImgUrl = x.downloadUrl
|
||||
})
|
||||
.catch();
|
||||
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
|
||||
.then(async (x) => {
|
||||
ImgUrl = x.downloadUrl;
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
const profileOc = await this.profileRepo.findOne({
|
||||
relations: [
|
||||
|
|
@ -450,107 +452,124 @@ export class ProfileController extends Controller {
|
|||
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
||||
: "",
|
||||
// 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({
|
||||
where: { profileId: id },
|
||||
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
||||
});
|
||||
const Cert = certs.length > 0
|
||||
? certs.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 Cert =
|
||||
certs.length > 0
|
||||
? certs.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 trainings = await this.trainingRepository.find({
|
||||
select: ["startDate", "endDate", "place", "department", "name"],
|
||||
where: { profileId: id },
|
||||
});
|
||||
const Training = trainings.length > 0
|
||||
? trainings.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 Training =
|
||||
trainings.length > 0
|
||||
? trainings.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 disciplines = await this.disciplineRepository.find({
|
||||
select: ["refCommandDate", "refCommandNo", "detail"],
|
||||
where: { profileId: id },
|
||||
});
|
||||
const Discipline = disciplines.length > 0
|
||||
? disciplines.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 =
|
||||
disciplines.length > 0
|
||||
? disciplines.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 educations = await this.educationRepository.find({
|
||||
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
|
||||
where: { profileId: id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
const Education = educations.length > 0
|
||||
? educations.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 Education =
|
||||
educations.length > 0
|
||||
? educations.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 salarys = await this.salaryRepository.find({
|
||||
select: [
|
||||
"date",
|
||||
|
|
@ -564,39 +583,46 @@ export class ProfileController extends Controller {
|
|||
"templateDoc",
|
||||
],
|
||||
where: { profileId: id },
|
||||
order: { order: "ASC" }
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
|
||||
const Salary = salarys.length > 0
|
||||
? salarys.map((item) => ({
|
||||
SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date)) : null,
|
||||
Position: item.position != null ? Extension.ToThaiNumber(item.position) : 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.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : 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 Salary =
|
||||
salarys.length > 0
|
||||
? salarys.map((item) => ({
|
||||
SalaryDate: item.date
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date))
|
||||
: null,
|
||||
Position: item.position != null ? Extension.ToThaiNumber(item.position) : 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.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : 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 insignias = await this.profileInsigniaRepo.find({
|
||||
relations: {
|
||||
|
|
@ -607,56 +633,62 @@ export class ProfileController extends Controller {
|
|||
where: { profileId: id },
|
||||
order: { receiveDate: "ASC" },
|
||||
});
|
||||
const Insignia = insignias.length > 0
|
||||
? insignias.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 =
|
||||
insignias.length > 0
|
||||
? insignias.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 leaves = await this.profileLeaveRepository.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId: id },
|
||||
order: { dateLeaveStart: "ASC" },
|
||||
});
|
||||
const Leave = leaves.length > 0
|
||||
? leaves.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 =
|
||||
leaves.length > 0
|
||||
? leaves.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: "-",
|
||||
},
|
||||
];
|
||||
|
||||
return new HttpSuccess({
|
||||
Profile: [Profile],
|
||||
|
|
@ -2604,7 +2636,7 @@ export class ProfileController extends Controller {
|
|||
@Get("{id}")
|
||||
async getProfile(@Request() req: RequestWithUser, @Path() id: string) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
let profile: any = await this.profileRepo.findOne({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
|
|
@ -2613,7 +2645,7 @@ export class ProfileController extends Controller {
|
|||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
profile.profileType = "OFFICER";
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
|
|
@ -3187,21 +3219,30 @@ export class ProfileController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalary"],
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"current_holders.orgRoot",
|
||||
"profileSalary",
|
||||
],
|
||||
order: {
|
||||
profileSalary: {
|
||||
order: "DESC",
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
let orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
|
|
@ -3209,9 +3250,9 @@ export class ProfileController extends Controller {
|
|||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
|
||||
|
||||
if (revisionId) {
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.id = :revisionId", { revisionId })
|
||||
.getOne();
|
||||
|
|
@ -3314,9 +3355,7 @@ export class ProfileController extends Controller {
|
|||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||
node: null,
|
||||
nodeId: null,
|
||||
salary: profile && profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0].amount
|
||||
: null
|
||||
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||
};
|
||||
|
||||
if (_profile.child4Id != null) {
|
||||
|
|
@ -3357,9 +3396,9 @@ export class ProfileController extends Controller {
|
|||
const orgRevisionPublish = await this.orgRevisionRepo.findOne({
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true
|
||||
}
|
||||
})
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
|
|
@ -3421,10 +3460,18 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
});
|
||||
const fullNameParts = [
|
||||
posMaster_ == null || posMaster_.orgChild4 == null ? null : posMaster_.orgChild4.orgChild4Name,
|
||||
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_.orgChild4 == null
|
||||
? null
|
||||
: posMaster_.orgChild4.orgChild4Name,
|
||||
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,
|
||||
];
|
||||
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
||||
|
|
@ -3539,7 +3586,7 @@ export class ProfileController extends Controller {
|
|||
let commanderAbovePosition_: any = {};
|
||||
let commanderAboveRootName_: any = {};
|
||||
let commanderAboveOrg_: any;
|
||||
let dataCommander: any
|
||||
let dataCommander: any;
|
||||
|
||||
commanderFullname_ =
|
||||
(findCmd?.current_holder?.prefix ?? "") +
|
||||
|
|
@ -3555,14 +3602,14 @@ export class ProfileController extends Controller {
|
|||
commanderAbovePosition_ = findOSAB?.current_holder?.position ?? "";
|
||||
|
||||
if (findCmd?.current_holderId == profile?.id) {
|
||||
commandProfileId = findOSAB?.current_holderId
|
||||
commandProfileId = findOSAB?.current_holderId;
|
||||
commanderFullname_ =
|
||||
(findOSAB?.current_holder?.prefix ?? "") +
|
||||
(findOSAB?.current_holder?.firstName ?? "") +
|
||||
(findOSAB?.current_holder?.firstName ? " " : "") +
|
||||
(findOSAB?.current_holder?.lastName ?? "");
|
||||
commanderPosition_ = findOSAB?.current_holder?.position ?? "";
|
||||
commandAboveProfileId = findTSAB?.current_holderId
|
||||
commandAboveProfileId = findTSAB?.current_holderId;
|
||||
commanderAboveFullname_ =
|
||||
(findTSAB?.current_holder?.prefix ?? "") +
|
||||
(findTSAB?.current_holder?.firstName ?? "") +
|
||||
|
|
@ -3575,10 +3622,9 @@ export class ProfileController extends Controller {
|
|||
commanderAboveFullname: commanderAboveFullname_,
|
||||
commanderAbovePosition: commanderAbovePosition_,
|
||||
};
|
||||
}
|
||||
else {
|
||||
commandProfileId = findCmd?.current_holderId
|
||||
commandAboveProfileId = findOSAB?.current_holderId
|
||||
} else {
|
||||
commandProfileId = findCmd?.current_holderId;
|
||||
commandAboveProfileId = findOSAB?.current_holderId;
|
||||
dataCommander = {
|
||||
commanderFullname: commanderFullname_,
|
||||
commanderPosition: commanderPosition_,
|
||||
|
|
@ -3586,7 +3632,7 @@ export class ProfileController extends Controller {
|
|||
commanderAbovePosition: commanderAbovePosition_,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const commandProfile = await this.profileRepo.findOne({
|
||||
where: { id: String(commandProfileId) },
|
||||
relations: ["current_holders", "current_holders.orgRoot"],
|
||||
|
|
@ -3594,9 +3640,11 @@ export class ProfileController extends Controller {
|
|||
|
||||
commanderRootName_ =
|
||||
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
|
||||
: commandProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
||||
: commandProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgRoot;
|
||||
//find สังกัดผู้บังคับบัญชา
|
||||
const commanderPosMaster_ = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
|
|
@ -3613,13 +3661,25 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
});
|
||||
const commanderFullNameParts = [
|
||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild4 == null ? null : commanderPosMaster_.orgChild4.orgChild4Name,
|
||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild3 == null ? 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,
|
||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild4 == null
|
||||
? null
|
||||
: commanderPosMaster_.orgChild4.orgChild4Name,
|
||||
commanderPosMaster_ == null || commanderPosMaster_.orgChild3 == null
|
||||
? 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({
|
||||
where: { id: String(commandAboveProfileId) },
|
||||
|
|
@ -3628,9 +3688,11 @@ export class ProfileController extends Controller {
|
|||
|
||||
commanderAboveRootName_ =
|
||||
commandAboveProfile?.current_holders == null ||
|
||||
commandAboveProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
||||
? null
|
||||
: commandAboveProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
||||
commandAboveProfile?.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgRoot == null
|
||||
? null
|
||||
: commandAboveProfile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgRoot;
|
||||
//find สังกัดผู้บังคับบัญชาเหนือไป1ขั้น
|
||||
const commanderAbovePosMaster_ = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
|
|
@ -3647,13 +3709,25 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
});
|
||||
const commanderAboveFullNameParts = [
|
||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild4 == null ? null : commanderAbovePosMaster_.orgChild4.orgChild4Name,
|
||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild3 == null ? 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,
|
||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild4 == null
|
||||
? null
|
||||
: commanderAbovePosMaster_.orgChild4.orgChild4Name,
|
||||
commanderAbovePosMaster_ == null || commanderAbovePosMaster_.orgChild3 == null
|
||||
? 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 = {
|
||||
profileId: profile.id,
|
||||
|
|
@ -3707,21 +3781,29 @@ export class ProfileController extends Controller {
|
|||
nodeId: null,
|
||||
org: org ? org : null,
|
||||
// commander: dataCommander,
|
||||
commanderFullname: dataCommander && dataCommander.commanderFullname
|
||||
? dataCommander.commanderFullname : null,
|
||||
commanderPosition: dataCommander && dataCommander.commanderPosition
|
||||
? dataCommander.commanderPosition : null,
|
||||
commanderRootName: commanderRootName_ && commanderRootName_.orgRootName
|
||||
? commanderRootName_.orgRootName : null,
|
||||
commanderFullname:
|
||||
dataCommander && dataCommander.commanderFullname ? dataCommander.commanderFullname : null,
|
||||
commanderPosition:
|
||||
dataCommander && dataCommander.commanderPosition ? dataCommander.commanderPosition : null,
|
||||
commanderRootName:
|
||||
commanderRootName_ && commanderRootName_.orgRootName
|
||||
? commanderRootName_.orgRootName
|
||||
: null,
|
||||
commanderOrg: commanderOrg_ ? commanderOrg_ : null,
|
||||
commanderAboveFullname: dataCommander && dataCommander.commanderAboveFullname
|
||||
? dataCommander.commanderAboveFullname : null,
|
||||
commanderAbovePosition: dataCommander && dataCommander.commanderAbovePosition
|
||||
? dataCommander.commanderAbovePosition : null,
|
||||
commanderAboveRootName: commanderAboveRootName_ && commanderAboveRootName_.orgRootName
|
||||
? commanderAboveRootName_.orgRootName : null,
|
||||
commanderAboveFullname:
|
||||
dataCommander && dataCommander.commanderAboveFullname
|
||||
? dataCommander.commanderAboveFullname
|
||||
: null,
|
||||
commanderAbovePosition:
|
||||
dataCommander && dataCommander.commanderAbovePosition
|
||||
? dataCommander.commanderAbovePosition
|
||||
: null,
|
||||
commanderAboveRootName:
|
||||
commanderAboveRootName_ && commanderAboveRootName_.orgRootName
|
||||
? commanderAboveRootName_.orgRootName
|
||||
: null,
|
||||
commanderAboveOrg: commanderAboveOrg_ ? commanderAboveOrg_ : null,
|
||||
};
|
||||
};
|
||||
|
||||
if (_profile.child4Id != null) {
|
||||
_profile.node = 4;
|
||||
|
|
|
|||
|
|
@ -1204,7 +1204,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Get("{id}")
|
||||
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
const profile: any = await this.profileRepo.findOne({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
|
|
@ -1216,6 +1216,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
profile.profileType = "EMPLOYEE";
|
||||
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
|
@ -1795,7 +1796,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
let orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
|
|
@ -1805,7 +1806,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
if (revisionId) {
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.id = :revisionId", { revisionId })
|
||||
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
||||
|
|
|
|||
|
|
@ -1558,7 +1558,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
let orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
|
|
@ -1568,7 +1568,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
if (revisionId) {
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.id = :revisionId", { revisionId })
|
||||
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue