profile emp
This commit is contained in:
parent
2f6fa989d6
commit
fa420d10ab
1 changed files with 159 additions and 1 deletions
|
|
@ -4126,7 +4126,164 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
const profile = await this.profileEmpRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"current_holders.orgRoot",
|
||||
"profileSalarys",
|
||||
],
|
||||
order: {
|
||||
profileSalarys: {
|
||||
order: "DESC",
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
|
||||
if (revisionId) {
|
||||
orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.id = :revisionId", { revisionId })
|
||||
.getOne();
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
}
|
||||
|
||||
const posMaster =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
||||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
||||
const child1 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgChild1;
|
||||
const child2 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgChild2;
|
||||
const child3 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgChild3;
|
||||
const child4 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
|
||||
?.orgChild4;
|
||||
|
||||
const position = await this.positionRepository.findOne({
|
||||
relations: ["posExecutive"],
|
||||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
profileId: profile.id,
|
||||
prefix: profile.prefix,
|
||||
rank: profile.rank,
|
||||
avatar: profile.avatar,
|
||||
isProbation: profile.isProbation,
|
||||
avatarName: profile.avatarName,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
birthDate: profile.birthDate,
|
||||
position: profile.position,
|
||||
leaveDate: profile.dateLeave,
|
||||
dateStart: profile.dateStart,
|
||||
dateRetireLaw: profile.dateRetireLaw,
|
||||
posMaster: posMaster == null ? null : posMaster.posMasterNo,
|
||||
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
||||
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
|
||||
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
||||
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
||||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||
posExecutiveName:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId:
|
||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||
rootId: root == null ? null : root.id,
|
||||
root: root == null ? null : root.orgRootName,
|
||||
rootShortName: root == null ? null : root.orgRootShortName,
|
||||
child1Id: child1 == null ? null : child1.id,
|
||||
child1: child1 == null ? null : child1.orgChild1Name,
|
||||
child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
|
||||
child2Id: child2 == null ? null : child2.id,
|
||||
child2: child2 == null ? null : child2.orgChild2Name,
|
||||
child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
|
||||
child3Id: child3 == null ? null : child3.id,
|
||||
child3: child3 == null ? null : child3.orgChild3Name,
|
||||
child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
|
||||
child4Id: child4 == null ? null : child4.id,
|
||||
child4: child4 == null ? null : child4.orgChild4Name,
|
||||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||
node: null,
|
||||
nodeId: null,
|
||||
type: "EMPLOYEE",
|
||||
salary:
|
||||
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
|
||||
};
|
||||
if (_profile.child4Id != null) {
|
||||
_profile.node = 4;
|
||||
_profile.nodeId = _profile.child4Id;
|
||||
} else if (_profile.child3Id != null) {
|
||||
_profile.node = 3;
|
||||
_profile.nodeId = _profile.child3Id;
|
||||
} else if (_profile.child2Id != null) {
|
||||
_profile.node = 2;
|
||||
_profile.nodeId = _profile.child2Id;
|
||||
} else if (_profile.child1Id != null) {
|
||||
_profile.node = 1;
|
||||
_profile.nodeId = _profile.child1Id;
|
||||
} else if (_profile.rootId != null) {
|
||||
_profile.node = 0;
|
||||
_profile.nodeId = _profile.rootId;
|
||||
}
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
|
|
@ -4242,6 +4399,7 @@ export class ProfileController extends Controller {
|
|||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||
node: null,
|
||||
nodeId: null,
|
||||
type: "OFFICER",
|
||||
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue