fix ส่งรายชื่อไปยังรายการอื่น ๆ #2571
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m10s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m10s
This commit is contained in:
parent
bbc6a5e6a9
commit
00c35e8974
2 changed files with 181 additions and 78 deletions
|
|
@ -8726,14 +8726,10 @@ export class ProfileController extends Controller {
|
||||||
"current_holders.orgChild2",
|
"current_holders.orgChild2",
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
// "profileSalary",
|
|
||||||
"profileEducations",
|
"profileEducations",
|
||||||
"profileActpositions",
|
"profileActpositions",
|
||||||
],
|
],
|
||||||
order: {
|
order: {
|
||||||
// profileSalary: {
|
|
||||||
// order: "DESC",
|
|
||||||
// },
|
|
||||||
profileEducations: {
|
profileEducations: {
|
||||||
level: "ASC",
|
level: "ASC",
|
||||||
},
|
},
|
||||||
|
|
@ -8798,72 +8794,6 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
const holder = profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
const holder = profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
||||||
const numPart = holder ? [holder.posMasterNoPrefix, holder.posMasterNo, holder.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
|
const numPart = holder ? [holder.posMasterNoPrefix, holder.posMasterNo, holder.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
|
||||||
const shortName =
|
|
||||||
holder == null
|
|
||||||
? null
|
|
||||||
: holder.orgChild4 != null
|
|
||||||
? `${holder.orgChild4.orgChild4ShortName} ${numPart}`
|
|
||||||
: holder.orgChild3 != null
|
|
||||||
? `${holder.orgChild3.orgChild3ShortName} ${numPart}`
|
|
||||||
: holder.orgChild2 != null
|
|
||||||
? `${holder.orgChild2.orgChild2ShortName} ${numPart}`
|
|
||||||
: holder.orgChild1 != null
|
|
||||||
? `${holder.orgChild1.orgChild1ShortName} ${numPart}`
|
|
||||||
: holder.orgRoot != null
|
|
||||||
? `${holder.orgRoot.orgRootShortName} ${numPart}`
|
|
||||||
: null;
|
|
||||||
// const posMasterActs = await this.posMasterActRepository.find({
|
|
||||||
// relations: [
|
|
||||||
// "posMaster",
|
|
||||||
// "posMaster.orgRoot",
|
|
||||||
// "posMaster.orgChild1",
|
|
||||||
// "posMaster.orgChild2",
|
|
||||||
// "posMaster.orgChild3",
|
|
||||||
// "posMaster.orgChild4",
|
|
||||||
// "posMaster.current_holder",
|
|
||||||
// "posMaster.current_holder.posLevel",
|
|
||||||
// "posMaster.current_holder.posType",
|
|
||||||
// ],
|
|
||||||
// where: {
|
|
||||||
// posMaster: {
|
|
||||||
// orgRevisionId: orgRevisionPublish.id,
|
|
||||||
// },
|
|
||||||
// posMasterChild: {
|
|
||||||
// current_holderId: profile.id,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// const data = await Promise.all(
|
|
||||||
// posMasterActs
|
|
||||||
// .sort((a, b) => a.posMaster.posMasterOrder - b.posMaster.posMasterOrder)
|
|
||||||
// .map((item) => {
|
|
||||||
// const shortName =
|
|
||||||
// item.posMaster != null && item.posMaster.orgChild4 != null
|
|
||||||
// ? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}`
|
|
||||||
// : item.posMaster != null && item.posMaster?.orgChild3 != null
|
|
||||||
// ? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}`
|
|
||||||
// : item.posMaster != null && item.posMaster?.orgChild2 != null
|
|
||||||
// ? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}`
|
|
||||||
// : item.posMaster != null && item.posMaster?.orgChild1 != null
|
|
||||||
// ? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}`
|
|
||||||
// : item.posMaster != null && item.posMaster?.orgRoot != null
|
|
||||||
// ? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}`
|
|
||||||
// : null;
|
|
||||||
// return {
|
|
||||||
// id: item.id,
|
|
||||||
// posMasterOrder: item.posMasterOrder,
|
|
||||||
// profileId: item.posMaster?.current_holder?.id ?? null,
|
|
||||||
// citizenId: item.posMaster?.current_holder?.citizenId ?? null,
|
|
||||||
// prefix: item.posMaster?.current_holder?.prefix ?? null,
|
|
||||||
// firstName: item.posMaster?.current_holder?.firstName ?? null,
|
|
||||||
// lastName: item.posMaster?.current_holder?.lastName ?? null,
|
|
||||||
// posLevel: item.posMaster?.current_holder?.posLevel?.posLevelName ?? null,
|
|
||||||
// posType: item.posMaster?.current_holder?.posType?.posTypeName ?? null,
|
|
||||||
// position: item.posMaster?.current_holder?.position ?? null,
|
|
||||||
// posNo: shortName,
|
|
||||||
// };
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
const data = await Promise.all(
|
const data = await Promise.all(
|
||||||
profile.profileActpositions
|
profile.profileActpositions
|
||||||
.filter((x) => x.status)
|
.filter((x) => x.status)
|
||||||
|
|
@ -8910,6 +8840,96 @@ export class ProfileController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _Org = null;
|
||||||
|
let _PosNo = null;
|
||||||
|
if (!profile.org && !profile.posMasterNo) {
|
||||||
|
if (profile.isLeave) {
|
||||||
|
const profileWithSalary = await this.profileRepo.findOne({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
profileSalary: {
|
||||||
|
commandCode: In([
|
||||||
|
"0",
|
||||||
|
"9",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"8",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12",
|
||||||
|
"13",
|
||||||
|
"14",
|
||||||
|
"15",
|
||||||
|
"16",
|
||||||
|
"20",
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
relations: { profileSalary: true },
|
||||||
|
order: {
|
||||||
|
profileSalary: {
|
||||||
|
order: "DESC",
|
||||||
|
createdAt: "DESC",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const profileSalaryList = profileWithSalary?.profileSalary || [];
|
||||||
|
|
||||||
|
if (profileSalaryList.length > 0) {
|
||||||
|
const _profileSalary =
|
||||||
|
profile.leaveType == "RETIRE"
|
||||||
|
? profileSalaryList.length > 1
|
||||||
|
? profileSalaryList[1]
|
||||||
|
: profileSalaryList[0]
|
||||||
|
: profileSalaryList[0];
|
||||||
|
|
||||||
|
if (_profileSalary) {
|
||||||
|
const orgLeaveParts = [
|
||||||
|
_profileSalary.orgChild4 ?? null,
|
||||||
|
_profileSalary.orgChild3 ?? null,
|
||||||
|
_profileSalary.orgChild2 ?? null,
|
||||||
|
_profileSalary.orgChild1 ?? null,
|
||||||
|
_profileSalary.orgRoot ?? null,
|
||||||
|
];
|
||||||
|
_Org = orgLeaveParts
|
||||||
|
.filter((x: any) => x !== undefined && x !== null)
|
||||||
|
.join("\n");
|
||||||
|
_PosNo = `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_Org = [
|
||||||
|
child4?.orgChild4Name,
|
||||||
|
child3?.orgChild3Name,
|
||||||
|
child2?.orgChild2Name,
|
||||||
|
child1?.orgChild1Name,
|
||||||
|
root?.orgRootName,
|
||||||
|
]
|
||||||
|
.filter((x) => x != null && x !== "")
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
_PosNo =
|
||||||
|
holder == null
|
||||||
|
? null
|
||||||
|
: holder.orgChild4 != null
|
||||||
|
? `${holder.orgChild4.orgChild4ShortName} ${numPart}`
|
||||||
|
: holder.orgChild3 != null
|
||||||
|
? `${holder.orgChild3.orgChild3ShortName} ${numPart}`
|
||||||
|
: holder.orgChild2 != null
|
||||||
|
? `${holder.orgChild2.orgChild2ShortName} ${numPart}`
|
||||||
|
: holder.orgChild1 != null
|
||||||
|
? `${holder.orgChild1.orgChild1ShortName} ${numPart}`
|
||||||
|
: holder.orgRoot != null
|
||||||
|
? `${holder.orgRoot.orgRootShortName} ${numPart}`
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_Org = profile.org;
|
||||||
|
_PosNo = profile.posMasterNo;
|
||||||
|
}
|
||||||
|
|
||||||
const _profile: any = {
|
const _profile: any = {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
prefix: profile.prefix,
|
prefix: profile.prefix,
|
||||||
|
|
@ -8961,7 +8981,8 @@ export class ProfileController extends Controller {
|
||||||
node: null,
|
node: null,
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
nodeDnaId: null,
|
nodeDnaId: null,
|
||||||
posNo: shortName,
|
posNo: _PosNo,
|
||||||
|
org: _Org,
|
||||||
isPosmasterAct: data.length > 0,
|
isPosmasterAct: data.length > 0,
|
||||||
posmasterAct: data,
|
posmasterAct: data,
|
||||||
salary: profile ? profile.amount : null,
|
salary: profile ? profile.amount : null,
|
||||||
|
|
|
||||||
|
|
@ -6462,6 +6462,92 @@ export class ProfileEmployeeController extends Controller {
|
||||||
? null
|
? null
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
||||||
const _numPart = posMaster ? [posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
|
const _numPart = posMaster ? [posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
|
||||||
|
|
||||||
|
// org / posNo — ล้อ fallback ของ officer (ProfileController.getProfileByProfileid)
|
||||||
|
// employee ไม่มี profile.org / profile.posMasterNo จึงแยกตาม isLeave โดยตรง
|
||||||
|
let _Org: string | null = null;
|
||||||
|
let _PosNo: string | null = null;
|
||||||
|
if (profile.isLeave) {
|
||||||
|
const profileWithSalary = await this.profileRepo.findOne({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
profileSalary: {
|
||||||
|
commandCode: In([
|
||||||
|
"0",
|
||||||
|
"9",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"8",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12",
|
||||||
|
"13",
|
||||||
|
"14",
|
||||||
|
"15",
|
||||||
|
"16",
|
||||||
|
"20",
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
relations: { profileSalary: true },
|
||||||
|
order: {
|
||||||
|
profileSalary: {
|
||||||
|
order: "DESC",
|
||||||
|
createdAt: "DESC",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const profileSalaryList = profileWithSalary?.profileSalary || [];
|
||||||
|
|
||||||
|
if (profileSalaryList.length > 0) {
|
||||||
|
const _profileSalary =
|
||||||
|
profile.leaveType == "RETIRE"
|
||||||
|
? profileSalaryList.length > 1
|
||||||
|
? profileSalaryList[1]
|
||||||
|
: profileSalaryList[0]
|
||||||
|
: profileSalaryList[0];
|
||||||
|
|
||||||
|
if (_profileSalary) {
|
||||||
|
_Org = [
|
||||||
|
_profileSalary.orgChild4 ?? null,
|
||||||
|
_profileSalary.orgChild3 ?? null,
|
||||||
|
_profileSalary.orgChild2 ?? null,
|
||||||
|
_profileSalary.orgChild1 ?? null,
|
||||||
|
_profileSalary.orgRoot ?? null,
|
||||||
|
]
|
||||||
|
.filter((x: any) => x !== undefined && x !== null)
|
||||||
|
.join("\n");
|
||||||
|
_PosNo = `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_Org = [
|
||||||
|
child4?.orgChild4Name,
|
||||||
|
child3?.orgChild3Name,
|
||||||
|
child2?.orgChild2Name,
|
||||||
|
child1?.orgChild1Name,
|
||||||
|
root?.orgRootName,
|
||||||
|
]
|
||||||
|
.filter((x) => x != null && x !== "")
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
_PosNo =
|
||||||
|
posMaster == null
|
||||||
|
? null
|
||||||
|
: child4 != null
|
||||||
|
? `${child4.orgChild4ShortName} ${_numPart}`
|
||||||
|
: child3 != null
|
||||||
|
? `${child3.orgChild3ShortName} ${_numPart}`
|
||||||
|
: child2 != null
|
||||||
|
? `${child2.orgChild2ShortName} ${_numPart}`
|
||||||
|
: child1 != null
|
||||||
|
? `${child1.orgChild1ShortName} ${_numPart}`
|
||||||
|
: root != null
|
||||||
|
? `${root.orgRootShortName} ${_numPart}`
|
||||||
|
: null;
|
||||||
|
}
|
||||||
const _profile: any = {
|
const _profile: any = {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
prefix: profile.prefix,
|
prefix: profile.prefix,
|
||||||
|
|
@ -6474,7 +6560,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
leaveDate: profile.dateLeave,
|
leaveDate: profile.dateLeave,
|
||||||
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
||||||
posLevelName: `${profile?.posType?.posTypeShortName ?? ""} ${profile?.posLevel?.posLevelName ?? ""}`,
|
posLevelName: `${profile?.posType?.posTypeShortName ?? ""} ${profile?.posLevel?.posLevelName ?? ""}`.trim(),
|
||||||
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
||||||
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
||||||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||||
|
|
@ -6503,7 +6589,8 @@ export class ProfileEmployeeController extends Controller {
|
||||||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||||
node: null,
|
node: null,
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
posNo: null,
|
posNo: _PosNo,
|
||||||
|
org: _Org,
|
||||||
salary: profile.amount,
|
salary: profile.amount,
|
||||||
education:
|
education:
|
||||||
profile && profile.profileEducations.length > 0
|
profile && profile.profileEducations.length > 0
|
||||||
|
|
@ -6518,27 +6605,22 @@ export class ProfileEmployeeController extends Controller {
|
||||||
_profile.node = 4;
|
_profile.node = 4;
|
||||||
_profile.nodeId = _profile.child4Id;
|
_profile.nodeId = _profile.child4Id;
|
||||||
_profile.nodeShortName = _profile.child4ShortName;
|
_profile.nodeShortName = _profile.child4ShortName;
|
||||||
_profile.posNo = `${_profile.child4ShortName} ${_numPart}`;
|
|
||||||
} else if (_profile.child3Id != null) {
|
} else if (_profile.child3Id != null) {
|
||||||
_profile.node = 3;
|
_profile.node = 3;
|
||||||
_profile.nodeId = _profile.child3Id;
|
_profile.nodeId = _profile.child3Id;
|
||||||
_profile.nodeShortName = _profile.child3ShortName;
|
_profile.nodeShortName = _profile.child3ShortName;
|
||||||
_profile.posNo = `${_profile.child3ShortName} ${_numPart}`;
|
|
||||||
} else if (_profile.child2Id != null) {
|
} else if (_profile.child2Id != null) {
|
||||||
_profile.node = 2;
|
_profile.node = 2;
|
||||||
_profile.nodeId = _profile.child2Id;
|
_profile.nodeId = _profile.child2Id;
|
||||||
_profile.nodeShortName = _profile.child2ShortName;
|
_profile.nodeShortName = _profile.child2ShortName;
|
||||||
_profile.posNo = `${_profile.child2ShortName} ${_numPart}`;
|
|
||||||
} else if (_profile.child1Id != null) {
|
} else if (_profile.child1Id != null) {
|
||||||
_profile.node = 1;
|
_profile.node = 1;
|
||||||
_profile.nodeId = _profile.child1Id;
|
_profile.nodeId = _profile.child1Id;
|
||||||
_profile.nodeShortName = _profile.child1ShortName;
|
_profile.nodeShortName = _profile.child1ShortName;
|
||||||
_profile.posNo = `${_profile.child1ShortName} ${_numPart}`;
|
|
||||||
} else if (_profile.rootId != null) {
|
} else if (_profile.rootId != null) {
|
||||||
_profile.node = 0;
|
_profile.node = 0;
|
||||||
_profile.nodeId = _profile.rootId;
|
_profile.nodeId = _profile.rootId;
|
||||||
_profile.nodeShortName = _profile.rootShortName;
|
_profile.nodeShortName = _profile.rootShortName;
|
||||||
_profile.posNo = `${_profile.rootShortName} ${_numPart}`;
|
|
||||||
}
|
}
|
||||||
return new HttpSuccess(_profile);
|
return new HttpSuccess(_profile);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue