This commit is contained in:
parent
9382482f06
commit
c8ed816a1f
2 changed files with 32 additions and 125 deletions
|
|
@ -5821,7 +5821,6 @@ export class CommandController extends Controller {
|
|||
body.data.map(async (item) => {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
relations: [
|
||||
// "profileSalary",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"current_holders",
|
||||
|
|
@ -5832,11 +5831,6 @@ export class CommandController extends Controller {
|
|||
"current_holders.orgChild4",
|
||||
],
|
||||
where: { id: item.profileId },
|
||||
// order: {
|
||||
// profileSalary: {
|
||||
// order: "DESC",
|
||||
// },
|
||||
// },
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||
|
|
@ -5848,46 +5842,19 @@ export class CommandController extends Controller {
|
|||
});
|
||||
const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
|
||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||
where: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
||||
const orgRevisionRef =
|
||||
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
||||
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
||||
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
||||
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
||||
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
||||
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
||||
const shortName =
|
||||
!profile.current_holders || profile.current_holders.length == 0
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||
?.orgChild4 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
|
||||
: null;
|
||||
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
|
||||
orgRevisionRef?.orgChild4?.orgChild4ShortName ??
|
||||
orgRevisionRef?.orgChild3?.orgChild3ShortName ??
|
||||
orgRevisionRef?.orgChild2?.orgChild2ShortName ??
|
||||
orgRevisionRef?.orgChild1?.orgChild1ShortName ??
|
||||
orgRevisionRef?.orgRoot?.orgRootShortName ??
|
||||
null;
|
||||
const posNo = orgRevisionRef?.posMasterNo?.toString() ?? null;
|
||||
let position =
|
||||
profile.current_holders
|
||||
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
||||
|
|
@ -5907,18 +5874,12 @@ export class CommandController extends Controller {
|
|||
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
||||
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||
// order:
|
||||
// profile.profileSalary.length >= 0
|
||||
// ? profile.profileSalary.length > 0
|
||||
// ? profile.profileSalary[0].order + 1
|
||||
// : 1
|
||||
// : null,
|
||||
order: nextOrder,
|
||||
orgRoot: orgRootRef?.orgRootName ?? null,
|
||||
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
|
||||
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
|
||||
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
|
||||
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
|
||||
orgRoot: orgRevisionRef?.orgRoot?.orgRootName ?? null,
|
||||
orgChild1: orgRevisionRef?.orgChild1?.orgChild1Name ?? null,
|
||||
orgChild2: orgRevisionRef?.orgChild2?.orgChild2Name ?? null,
|
||||
orgChild3: orgRevisionRef?.orgChild3?.orgChild3Name ?? null,
|
||||
orgChild4: orgRevisionRef?.orgChild4?.orgChild4Name ?? null,
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
|
|
@ -5944,19 +5905,8 @@ export class CommandController extends Controller {
|
|||
await this.salaryHistoryRepo.save(history);
|
||||
}),
|
||||
);
|
||||
// const checkCommandType = await this.commandRepository.findOne({
|
||||
// where: { id: body.data.length > 0 ? body.data[0].commandId?.toString() : "" },
|
||||
// relations: ["commandType"],
|
||||
// });
|
||||
|
||||
if (commandType && String(commandType.code) == "C-PM-11") {
|
||||
// const profile = await this.profileRepository.find({
|
||||
// where: { id: In(body.data.map((x) => x.profileId)) },
|
||||
// });
|
||||
// const data = profile.map((x) => ({
|
||||
// ...x,
|
||||
// isProbation: false,
|
||||
// }));
|
||||
// await this.profileRepository.save(data);
|
||||
const profileIds = body.data.map((x) => x.profileId);
|
||||
await this.profileRepository.update(
|
||||
{ id: In(profileIds) },
|
||||
|
|
@ -5976,6 +5926,8 @@ export class CommandController extends Controller {
|
|||
beginningLeaveDays: 0,
|
||||
beginningLeaveCount: 0,
|
||||
})
|
||||
.then(() => {})
|
||||
.catch(() => {})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue