no message

This commit is contained in:
kittapath 2024-11-18 17:23:40 +07:00
parent 3c9698f606
commit 9e78cf7345

View file

@ -514,7 +514,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -749,7 +751,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -1043,7 +1047,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -1308,7 +1314,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -1632,7 +1640,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -1897,7 +1907,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
amountd: profile.amount, amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
root: root:
profile?.current_holders?.find( profile?.current_holders?.find(
(x) => (x) =>
@ -1979,12 +1991,20 @@ export class OrganizationDotnetController extends Controller {
@Get("root/officer/{rootId}") @Get("root/officer/{rootId}")
async GetProfileByRootIdAsync(@Path() rootId: string) { async GetProfileByRootIdAsync(@Path() rootId: string) {
const profiles = await this.profileRepo.find({ const profiles = await this.profileRepo.find({
relations: { relations: [
posLevel: true, "posLevel",
posType: true, "posType",
profileSalary: true, "profileSalary",
profileInsignias: true, "profileInsignias",
}, "profileInsignias.insignia",
"current_holders",
"current_holders.orgRevision",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: { current_holders: { orgRootId: rootId } }, where: { current_holders: { orgRootId: rootId } },
order: { order: {
profileSalary: { profileSalary: {
@ -1995,9 +2015,40 @@ export class OrganizationDotnetController extends Controller {
}, },
}, },
}); });
// if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const mapProfile = profiles.map((profile) => ({ const findRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
});
const mapProfile = profiles.map((profile) => {
const shortName =
profile.current_holders.length == 0
? null
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: null;
return {
id: profile.id, id: profile.id,
avatar: profile.avatar, avatar: profile.avatar,
avatarName: profile.avatarName, avatarName: profile.avatarName,
@ -2008,6 +2059,7 @@ export class OrganizationDotnetController extends Controller {
citizenId: profile.citizenId, citizenId: profile.citizenId,
position: profile.position, position: profile.position,
posLevelId: profile.posLevelId, posLevelId: profile.posLevelId,
posTypeId: profile.posTypeId,
email: profile.email, email: profile.email,
phone: profile.phone, phone: profile.phone,
keycloak: profile.keycloak, keycloak: profile.keycloak,
@ -2042,8 +2094,28 @@ export class OrganizationDotnetController extends Controller {
posLevel: profile.posLevel ? profile.posLevel : null, posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType ? profile.posType : null, posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalary, profileSalary: profile.profileSalary,
profileInsignia: profile.profileInsignias, profileInsignia: profile.profileInsignias.map((x) => {
})); return { ...x, insignia: x.insignia.name };
}),
amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
profileType: "OFFICER",
root:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.orgRootName ?? null,
rootId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRootId ?? null,
posNo: shortName,
};
});
return new HttpSuccess(mapProfile); return new HttpSuccess(mapProfile);
} }
@ -2058,12 +2130,20 @@ export class OrganizationDotnetController extends Controller {
@Get("root/employee/{rootId}") @Get("root/employee/{rootId}")
async GetProfileByRootIdEmpAsync(@Path() rootId: string) { async GetProfileByRootIdEmpAsync(@Path() rootId: string) {
const profiles = await this.profileEmpRepo.find({ const profiles = await this.profileEmpRepo.find({
relations: { relations: [
posLevel: true, "posLevel",
posType: true, "posType",
profileSalary: true, "profileSalary",
profileInsignias: true, "profileInsignias",
}, "profileInsignias.insignia",
"current_holders",
"current_holders.orgRevision",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: { current_holders: { orgRootId: rootId } }, where: { current_holders: { orgRootId: rootId } },
order: { order: {
profileSalary: { profileSalary: {
@ -2074,9 +2154,39 @@ export class OrganizationDotnetController extends Controller {
}, },
}, },
}); });
// if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const mapProfile = profiles.map((profile) => ({ const findRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
});
const mapProfile = profiles.map((profile) => {
const shortName =
profile.current_holders.length == 0
? null
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: null;
return {
id: profile.id, id: profile.id,
avatar: profile.avatar, avatar: profile.avatar,
avatarName: profile.avatarName, avatarName: profile.avatarName,
@ -2121,8 +2231,28 @@ export class OrganizationDotnetController extends Controller {
posLevel: profile.posLevel ? profile.posLevel : null, posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType ? profile.posType : null, posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalary, profileSalary: profile.profileSalary,
profileInsignia: profile.profileInsignias, profileInsignia: profile.profileInsignias.map((x) => {
})); return { ...x, insignia: x.insignia.name };
}),
amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
profileType: "OFFICER",
root:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.orgRootName ?? null,
rootId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRootId ?? null,
posNo: shortName,
};
});
return new HttpSuccess(mapProfile); return new HttpSuccess(mapProfile);
} }