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.orgChild3",
|
||||
"current_holders.orgChild4",
|
||||
// "profileSalary",
|
||||
"profileEducations",
|
||||
"profileActpositions",
|
||||
],
|
||||
order: {
|
||||
// profileSalary: {
|
||||
// order: "DESC",
|
||||
// },
|
||||
profileEducations: {
|
||||
level: "ASC",
|
||||
},
|
||||
|
|
@ -8798,72 +8794,6 @@ export class ProfileController extends Controller {
|
|||
});
|
||||
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 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(
|
||||
profile.profileActpositions
|
||||
.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 = {
|
||||
profileId: profile.id,
|
||||
prefix: profile.prefix,
|
||||
|
|
@ -8961,7 +8981,8 @@ export class ProfileController extends Controller {
|
|||
node: null,
|
||||
nodeId: null,
|
||||
nodeDnaId: null,
|
||||
posNo: shortName,
|
||||
posNo: _PosNo,
|
||||
org: _Org,
|
||||
isPosmasterAct: data.length > 0,
|
||||
posmasterAct: data,
|
||||
salary: profile ? profile.amount : null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue