sort edu by level
This commit is contained in:
parent
4b05629c29
commit
587fe5d5b6
11 changed files with 229 additions and 266 deletions
|
|
@ -624,9 +624,9 @@ export class CommandController extends Controller {
|
|||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
order: {
|
||||
commandSends : {
|
||||
createdAt: "ASC"
|
||||
}
|
||||
commandSends: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
},
|
||||
relations: ["commandSends", "commandSends.commandSendCCs"],
|
||||
});
|
||||
|
|
@ -642,9 +642,7 @@ export class CommandController extends Controller {
|
|||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
org: item.org,
|
||||
sendCC: item.commandSendCCs
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((x) => x.name),
|
||||
sendCC: item.commandSendCCs.sort((a, b) => a.name.localeCompare(b.name)).map((x) => x.name),
|
||||
profileId: item.profileId,
|
||||
}));
|
||||
return new HttpSuccess(_command);
|
||||
|
|
@ -1334,7 +1332,7 @@ export class CommandController extends Controller {
|
|||
});
|
||||
if (profile != null) {
|
||||
issue =
|
||||
orgRevisionActive?.posMasters?.filter((x:any) => x.current_holderId == profile.id)[0]
|
||||
orgRevisionActive?.posMasters?.filter((x: any) => x.current_holderId == profile.id)[0]
|
||||
?.orgRoot?.orgRootName || null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1397,16 +1395,16 @@ export class CommandController extends Controller {
|
|||
};
|
||||
} else {
|
||||
let _persons: any;
|
||||
_persons = await Promise.all(
|
||||
command.commandRecives.map(async(x, idx) => {
|
||||
_persons = await Promise.all(
|
||||
command.commandRecives.map(async (x, idx) => {
|
||||
const profile = await this.profileEmployeeRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
id: x.profileId,
|
||||
},
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"current_holders.orgRevision",
|
||||
"current_holders.orgRoot",
|
||||
"current_holders.orgChild1",
|
||||
|
|
@ -1418,65 +1416,78 @@ export class CommandController extends Controller {
|
|||
const shortName =
|
||||
profile?.current_holders.length == 0
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 !=
|
||||
null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild4 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
: profile?.current_holders.find(
|
||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||
) != null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1 != null
|
||||
: profile?.current_holders.find(
|
||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||
) != null &&
|
||||
profile?.current_holders.find(
|
||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||
)?.orgChild1 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgRoot != null
|
||||
: profile?.current_holders.find(
|
||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||
) != null &&
|
||||
profile?.current_holders.find(
|
||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||
)?.orgRoot != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
|
||||
const root =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgRoot;
|
||||
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||
?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1;
|
||||
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||
?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2;
|
||||
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||
?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3;
|
||||
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||
?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4;
|
||||
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||
?.orgChild4;
|
||||
|
||||
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`;
|
||||
|
|
@ -1484,33 +1495,30 @@ export class CommandController extends Controller {
|
|||
let _root = root == null ? "" : `${root.orgRootName}`;
|
||||
|
||||
return {
|
||||
no: Extension.ToThaiNumber((idx+1).toString()),
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
org: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
||||
citizenId: Extension.ToThaiNumber(x.citizenId),
|
||||
position: profile?.position
|
||||
? profile?.position
|
||||
: "-",
|
||||
posLevel: profile?.posType && profile?.posLevel
|
||||
? Extension.ToThaiNumber(`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`)
|
||||
: "-",
|
||||
posNo: shortName
|
||||
? Extension.ToThaiNumber(shortName)
|
||||
: "-",
|
||||
amount: x.amount
|
||||
? Extension.ToThaiNumber(x.amount.toString())
|
||||
: "-",
|
||||
dateRetire: profile?.dateRetire
|
||||
position: profile?.position ? profile?.position : "-",
|
||||
posLevel:
|
||||
profile?.posType && profile?.posLevel
|
||||
? Extension.ToThaiNumber(
|
||||
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
|
||||
)
|
||||
: "-",
|
||||
posNo: shortName ? Extension.ToThaiNumber(shortName) : "-",
|
||||
amount: x.amount ? Extension.ToThaiNumber(x.amount.toString()) : "-",
|
||||
dateRetire: profile?.dateRetire
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
|
||||
: "-",
|
||||
dateExecute: command.commandExcecuteDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate))
|
||||
: "-",
|
||||
remark: x.remarkVertical
|
||||
? x.remarkVertical
|
||||
: "-"
|
||||
}
|
||||
})
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),
|
||||
)
|
||||
: "-",
|
||||
remark: x.remarkVertical ? x.remarkVertical : "-",
|
||||
};
|
||||
}),
|
||||
);
|
||||
_command = {
|
||||
issue: issue,
|
||||
|
|
@ -1552,7 +1560,7 @@ export class CommandController extends Controller {
|
|||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
persons: _persons
|
||||
persons: _persons,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -2095,7 +2103,7 @@ export class CommandController extends Controller {
|
|||
|
||||
if (["C-PM-10"].includes(commandCode)) {
|
||||
await Promise.all(
|
||||
requestBody.persons.map(async (item:any) => {
|
||||
requestBody.persons.map(async (item: any) => {
|
||||
const _posMasterDirector = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRootId: item.rootId,
|
||||
|
|
@ -2103,11 +2111,11 @@ export class CommandController extends Controller {
|
|||
current_holderId: item.profileId,
|
||||
},
|
||||
relations: ["current_holder", "orgRoot", "positions"],
|
||||
});
|
||||
});
|
||||
const _commandSend = await this.commandSendRepository.findOne({
|
||||
where: {
|
||||
commandId: command.id,
|
||||
profileId: item.profileId ?? null_
|
||||
profileId: item.profileId ?? null_,
|
||||
},
|
||||
});
|
||||
if (!_commandSend) {
|
||||
|
|
@ -2116,12 +2124,14 @@ export class CommandController extends Controller {
|
|||
commandSend.prefix = item.prefix;
|
||||
commandSend.firstName = item.firstName;
|
||||
commandSend.lastName = item.lastName;
|
||||
commandSend.position = _posMasterDirector && _posMasterDirector.positions.length > 0
|
||||
? _posMasterDirector.positions[0].positionName
|
||||
: null_;
|
||||
commandSend.org = _posMasterDirector && _posMasterDirector.orgRoot
|
||||
? _posMasterDirector.orgRoot.orgRootName
|
||||
: null_;
|
||||
commandSend.position =
|
||||
_posMasterDirector && _posMasterDirector.positions.length > 0
|
||||
? _posMasterDirector.positions[0].positionName
|
||||
: null_;
|
||||
commandSend.org =
|
||||
_posMasterDirector && _posMasterDirector.orgRoot
|
||||
? _posMasterDirector.orgRoot.orgRootName
|
||||
: null_;
|
||||
commandSend.profileId = item.profileId;
|
||||
commandSend.commandId = command.id;
|
||||
commandSend.createdUserId = request.user.sub;
|
||||
|
|
@ -2149,10 +2159,9 @@ export class CommandController extends Controller {
|
|||
await this.commandSendCCRepository.save(_dataSendCC);
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
return new HttpSuccess(command.id);
|
||||
}
|
||||
|
|
@ -3786,6 +3795,12 @@ export class CommandController extends Controller {
|
|||
const eduHistory = new ProfileEducationHistory();
|
||||
Object.assign(eduHistory, { ...profileEdu, id: undefined });
|
||||
profileEdu.profileId = profile.id;
|
||||
const educationLevel = await this.profileEducationRepo.findOne({
|
||||
select: ["id", "level", "profileId"],
|
||||
where: { profileId: profile.id },
|
||||
order: { level: "DESC" },
|
||||
});
|
||||
profileEdu.level = educationLevel == null ? 1 : educationLevel.level + 1;
|
||||
await this.profileEducationRepo.save(profileEdu, { data: req });
|
||||
setLogDataDiff(req, { before, after: profileEdu });
|
||||
eduHistory.profileEducationId = profileEdu.id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue