This commit is contained in:
parent
91887ec63d
commit
060ac81532
4 changed files with 201 additions and 123 deletions
|
|
@ -101,6 +101,7 @@ import {
|
||||||
} from "../services/PositionService";
|
} from "../services/PositionService";
|
||||||
import { PostRetireToExprofile } from "./ExRetirementController";
|
import { PostRetireToExprofile } from "./ExRetirementController";
|
||||||
import { LeaveType } from "../entities/LeaveType";
|
import { LeaveType } from "../entities/LeaveType";
|
||||||
|
import { KeycloakAttributeService } from "../services/KeycloakAttributeService";
|
||||||
@Route("api/v1/org/command")
|
@Route("api/v1/org/command")
|
||||||
@Tags("Command")
|
@Tags("Command")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -157,6 +158,8 @@ export class CommandController extends Controller {
|
||||||
private genderRepo = AppDataSource.getRepository(Gender);
|
private genderRepo = AppDataSource.getRepository(Gender);
|
||||||
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
||||||
private leaveType = AppDataSource.getRepository(LeaveType);
|
private leaveType = AppDataSource.getRepository(LeaveType);
|
||||||
|
private keycloakAttributeService = new KeycloakAttributeService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API list รายการคำสั่ง
|
* API list รายการคำสั่ง
|
||||||
*
|
*
|
||||||
|
|
@ -188,12 +191,12 @@ export class CommandController extends Controller {
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true && x.orgRevision?.orgRevisionIsDraft == false,
|
x.orgRevision?.orgRevisionIsCurrent == true && x.orgRevision?.orgRevisionIsDraft == false,
|
||||||
)[0]?.isDirector || false;
|
)[0]?.isDirector || false;
|
||||||
let _data: any = {
|
let _data: any = {
|
||||||
root: null,
|
root: null,
|
||||||
child1: null,
|
child1: null,
|
||||||
child2: null,
|
child2: null,
|
||||||
child3: null,
|
child3: null,
|
||||||
child4: null,
|
child4: null,
|
||||||
};
|
};
|
||||||
if (!request.user.role.includes("SUPER_ADMIN")) {
|
if (!request.user.role.includes("SUPER_ADMIN")) {
|
||||||
_data = await new permission().PermissionOrgList(request, "COMMAND");
|
_data = await new permission().PermissionOrgList(request, "COMMAND");
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +234,7 @@ export class CommandController extends Controller {
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `current_holders.orgChild1Id IN (:...child1)`
|
? `current_holders.orgChild1Id IN (:...child1)`
|
||||||
: // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
: // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
`current_holders.orgChild1Id is null`
|
`current_holders.orgChild1Id is null`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -309,7 +312,7 @@ export class CommandController extends Controller {
|
||||||
status == null || status == undefined || status == ""
|
status == null || status == undefined || status == ""
|
||||||
? null
|
? null
|
||||||
: status.trim().toLocaleUpperCase() == "NEW" ||
|
: status.trim().toLocaleUpperCase() == "NEW" ||
|
||||||
status.trim().toLocaleUpperCase() == "DRAFT"
|
status.trim().toLocaleUpperCase() == "DRAFT"
|
||||||
? ["NEW", "DRAFT"]
|
? ["NEW", "DRAFT"]
|
||||||
: [status.trim().toLocaleUpperCase()],
|
: [status.trim().toLocaleUpperCase()],
|
||||||
},
|
},
|
||||||
|
|
@ -810,8 +813,8 @@ export class CommandController extends Controller {
|
||||||
.PostData(request, path + "/delete", {
|
.PostData(request, path + "/delete", {
|
||||||
refIds: [commandRecive.refId],
|
refIds: [commandRecive.refId],
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
const commandId = commandRecive.commandId;
|
const commandId = commandRecive.commandId;
|
||||||
await this.commandReciveRepository.delete(commandRecive.id);
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
@ -854,8 +857,8 @@ export class CommandController extends Controller {
|
||||||
.PostData(request, path + "/delete", {
|
.PostData(request, path + "/delete", {
|
||||||
refIds: [commandRecive.refId],
|
refIds: [commandRecive.refId],
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
const commandId = commandRecive.commandId;
|
const commandId = commandRecive.commandId;
|
||||||
await this.commandReciveRepository.delete(commandRecive.id);
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
@ -898,8 +901,8 @@ export class CommandController extends Controller {
|
||||||
.PostData(request, path + "/delete", {
|
.PostData(request, path + "/delete", {
|
||||||
refIds: [commandRecive.refId],
|
refIds: [commandRecive.refId],
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
const commandId = commandRecive.commandId;
|
const commandId = commandRecive.commandId;
|
||||||
await this.commandReciveRepository.delete(commandRecive.id);
|
await this.commandReciveRepository.delete(commandRecive.id);
|
||||||
|
|
@ -1183,8 +1186,8 @@ export class CommandController extends Controller {
|
||||||
.PostData(request, path + "/delete", {
|
.PostData(request, path + "/delete", {
|
||||||
refIds: command.commandRecives.map((x) => x.refId),
|
refIds: command.commandRecives.map((x) => x.refId),
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
await this.commandReciveRepository.delete({ commandId: command.id });
|
await this.commandReciveRepository.delete({ commandId: command.id });
|
||||||
command.status = "CANCEL";
|
command.status = "CANCEL";
|
||||||
|
|
@ -1249,8 +1252,8 @@ export class CommandController extends Controller {
|
||||||
.PostData(request, path + "/delete", {
|
.PostData(request, path + "/delete", {
|
||||||
refIds: command.commandRecives.map((x) => x.refId),
|
refIds: command.commandRecives.map((x) => x.refId),
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
|
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
|
||||||
await this.commandReciveRepository.delete({ commandId: command.id });
|
await this.commandReciveRepository.delete({ commandId: command.id });
|
||||||
|
|
@ -1403,11 +1406,11 @@ export class CommandController extends Controller {
|
||||||
let profiles =
|
let profiles =
|
||||||
command && command.commandRecives.length > 0
|
command && command.commandRecives.length > 0
|
||||||
? command.commandRecives
|
? command.commandRecives
|
||||||
.filter((x) => x.profileId != null)
|
.filter((x) => x.profileId != null)
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
receiverUserId: x.profileId,
|
receiverUserId: x.profileId,
|
||||||
notiLink: "",
|
notiLink: "",
|
||||||
}))
|
}))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const msgNoti = {
|
const msgNoti = {
|
||||||
|
|
@ -1439,8 +1442,8 @@ export class CommandController extends Controller {
|
||||||
refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId),
|
refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId),
|
||||||
status: "WAITING",
|
status: "WAITING",
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
await this.commandRepository.save(command);
|
await this.commandRepository.save(command);
|
||||||
} else {
|
} else {
|
||||||
const path = commandTypePath(command.commandType.code);
|
const path = commandTypePath(command.commandType.code);
|
||||||
|
|
@ -1577,7 +1580,7 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
await this.profileRepository.save(profiles);
|
await this.profileRepository.save(profiles);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
|
|
||||||
type = "EMPLOYEE";
|
type = "EMPLOYEE";
|
||||||
try {
|
try {
|
||||||
|
|
@ -1609,7 +1612,7 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
await this.profileEmployeeRepository.save(profiles);
|
await this.profileEmployeeRepository.save(profiles);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1673,7 +1676,7 @@ export class CommandController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
|
|
||||||
type = "EMPLOYEE";
|
type = "EMPLOYEE";
|
||||||
try {
|
try {
|
||||||
|
|
@ -1728,7 +1731,7 @@ export class CommandController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1941,7 +1944,7 @@ export class CommandController extends Controller {
|
||||||
.then((x) => {
|
.then((x) => {
|
||||||
res = x;
|
res = x;
|
||||||
})
|
})
|
||||||
.catch((x) => {});
|
.catch((x) => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
let _command;
|
let _command;
|
||||||
|
|
@ -2019,76 +2022,76 @@ export class CommandController extends Controller {
|
||||||
profile?.current_holders.length == 0
|
profile?.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||||
null &&
|
null &&
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
?.orgChild4 != null
|
?.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)?.orgChild4.orgChild4ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||||
null &&
|
null &&
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
?.orgChild3 != null
|
?.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)?.orgChild3.orgChild3ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||||
: profile?.current_holders.find(
|
: profile?.current_holders.find(
|
||||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||||
) != null &&
|
) != null &&
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
?.orgChild2 != null
|
?.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)?.orgChild2.orgChild2ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||||
: profile?.current_holders.find(
|
: profile?.current_holders.find(
|
||||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||||
) != null &&
|
) != null &&
|
||||||
profile?.current_holders.find(
|
profile?.current_holders.find(
|
||||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||||
)?.orgChild1 != null
|
)?.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)?.orgChild1.orgChild1ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||||
: profile?.current_holders.find(
|
: profile?.current_holders.find(
|
||||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||||
) != null &&
|
) != null &&
|
||||||
profile?.current_holders.find(
|
profile?.current_holders.find(
|
||||||
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
(x) => x.orgRevisionId == orgRevisionActive?.id,
|
||||||
)?.orgRoot != null
|
)?.orgRoot != null
|
||||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const root =
|
const root =
|
||||||
profile?.current_holders == null ||
|
profile?.current_holders == null ||
|
||||||
profile?.current_holders.length == 0 ||
|
profile?.current_holders.length == 0 ||
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgRoot;
|
?.orgRoot;
|
||||||
|
|
||||||
const child1 =
|
const child1 =
|
||||||
profile?.current_holders == null ||
|
profile?.current_holders == null ||
|
||||||
profile?.current_holders.length == 0 ||
|
profile?.current_holders.length == 0 ||
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild1;
|
?.orgChild1;
|
||||||
|
|
||||||
const child2 =
|
const child2 =
|
||||||
profile?.current_holders == null ||
|
profile?.current_holders == null ||
|
||||||
profile?.current_holders.length == 0 ||
|
profile?.current_holders.length == 0 ||
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild2;
|
?.orgChild2;
|
||||||
|
|
||||||
const child3 =
|
const child3 =
|
||||||
profile?.current_holders == null ||
|
profile?.current_holders == null ||
|
||||||
profile?.current_holders.length == 0 ||
|
profile?.current_holders.length == 0 ||
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild3;
|
?.orgChild3;
|
||||||
|
|
||||||
const child4 =
|
const child4 =
|
||||||
profile?.current_holders == null ||
|
profile?.current_holders == null ||
|
||||||
profile?.current_holders.length == 0 ||
|
profile?.current_holders.length == 0 ||
|
||||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||||
? null
|
? null
|
||||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
|
||||||
?.orgChild4;
|
?.orgChild4;
|
||||||
|
|
||||||
let _root = root?.orgRootName;
|
let _root = root?.orgRootName;
|
||||||
let _child1 = child1?.orgChild1Name;
|
let _child1 = child1?.orgChild1Name;
|
||||||
|
|
@ -2149,10 +2152,10 @@ export class CommandController extends Controller {
|
||||||
commandCode != "C-PM-21"
|
commandCode != "C-PM-21"
|
||||||
? profile?.isLeave == false
|
? profile?.isLeave == false
|
||||||
? (_child4 == null ? "" : _child4 + "\n") +
|
? (_child4 == null ? "" : _child4 + "\n") +
|
||||||
(_child3 == null ? "" : _child3 + "\n") +
|
(_child3 == null ? "" : _child3 + "\n") +
|
||||||
(_child2 == null ? "" : _child2 + "\n") +
|
(_child2 == null ? "" : _child2 + "\n") +
|
||||||
(_child1 == null ? "" : _child1 + "\n") +
|
(_child1 == null ? "" : _child1 + "\n") +
|
||||||
(_root == null ? "" : _root)
|
(_root == null ? "" : _root)
|
||||||
: orgLeave
|
: orgLeave
|
||||||
: profileTemp.org,
|
: profileTemp.org,
|
||||||
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
||||||
|
|
@ -2167,8 +2170,8 @@ export class CommandController extends Controller {
|
||||||
commandCode != "C-PM-21"
|
commandCode != "C-PM-21"
|
||||||
? profile?.posType && profile?.posLevel
|
? profile?.posType && profile?.posLevel
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
|
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
|
||||||
)
|
)
|
||||||
: "-"
|
: "-"
|
||||||
: Extension.ToThaiNumber(profileTemp.posLevel),
|
: Extension.ToThaiNumber(profileTemp.posLevel),
|
||||||
posNo:
|
posNo:
|
||||||
|
|
@ -2182,19 +2185,19 @@ export class CommandController extends Controller {
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
|
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
|
||||||
: profile?.birthDate && commandCode == "C-PM-21"
|
: profile?.birthDate && commandCode == "C-PM-21"
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
Extension.ToThaiShortDate_monthYear(
|
Extension.ToThaiShortDate_monthYear(
|
||||||
new Date(
|
new Date(
|
||||||
profile.birthDate.getFullYear() + 60,
|
profile.birthDate.getFullYear() + 60,
|
||||||
profile.birthDate.getMonth(),
|
profile.birthDate.getMonth(),
|
||||||
profile.birthDate.getDate(),
|
profile.birthDate.getDate(),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
)
|
||||||
: "-",
|
: "-",
|
||||||
dateExecute: command.commandExcecuteDate
|
dateExecute: command.commandExcecuteDate
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),
|
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),
|
||||||
)
|
)
|
||||||
: "-",
|
: "-",
|
||||||
remark: x.remarkVertical ? x.remarkVertical : "-",
|
remark: x.remarkVertical ? x.remarkVertical : "-",
|
||||||
};
|
};
|
||||||
|
|
@ -2295,7 +2298,7 @@ export class CommandController extends Controller {
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
_command = res;
|
_command = res;
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
let issue =
|
let issue =
|
||||||
command.isBangkok == "OFFICE"
|
command.isBangkok == "OFFICE"
|
||||||
|
|
@ -2353,15 +2356,15 @@ export class CommandController extends Controller {
|
||||||
operators:
|
operators:
|
||||||
operators.length > 0
|
operators.length > 0
|
||||||
? operators.map((x) => ({
|
? operators.map((x) => ({
|
||||||
fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`,
|
fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`,
|
||||||
roleName: x.roleName,
|
roleName: x.roleName,
|
||||||
}))
|
}))
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
fullName: "",
|
fullName: "",
|
||||||
roleName: "เจ้าหน้าที่ดำเนินการ",
|
roleName: "เจ้าหน้าที่ดำเนินการ",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2666,8 +2669,8 @@ export class CommandController extends Controller {
|
||||||
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
||||||
status: "REPORT",
|
status: "REPORT",
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
let order =
|
let order =
|
||||||
command.commandRecives == null || command.commandRecives.length <= 0
|
command.commandRecives == null || command.commandRecives.length <= 0
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -3440,27 +3443,27 @@ export class CommandController extends Controller {
|
||||||
? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
|
||||||
: x.orgChild3 == null
|
: x.orgChild3 == null
|
||||||
? x.orgChild2.orgChild2Name +
|
? x.orgChild2.orgChild2Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild1.orgChild1Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgRoot.orgRootName
|
||||||
|
: x.orgChild4 == null
|
||||||
|
? x.orgChild3.orgChild3Name +
|
||||||
|
"\n" +
|
||||||
|
x.orgChild2.orgChild2Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgChild1.orgChild1Name +
|
x.orgChild1.orgChild1Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgRoot.orgRootName
|
x.orgRoot.orgRootName
|
||||||
: x.orgChild4 == null
|
|
||||||
? x.orgChild3.orgChild3Name +
|
|
||||||
"\n" +
|
|
||||||
x.orgChild2.orgChild2Name +
|
|
||||||
"\n" +
|
|
||||||
x.orgChild1.orgChild1Name +
|
|
||||||
"\n" +
|
|
||||||
x.orgRoot.orgRootName
|
|
||||||
: x.orgChild4.orgChild4Name +
|
: x.orgChild4.orgChild4Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgChild3.orgChild3Name +
|
x.orgChild3.orgChild3Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgChild2.orgChild2Name +
|
x.orgChild2.orgChild2Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgChild1.orgChild1Name +
|
x.orgChild1.orgChild1Name +
|
||||||
"\n" +
|
"\n" +
|
||||||
x.orgRoot.orgRootName,
|
x.orgRoot.orgRootName,
|
||||||
positionName: x?.current_holder.position ?? _null,
|
positionName: x?.current_holder.position ?? _null,
|
||||||
profileId: x?.current_holder.id ?? _null,
|
profileId: x?.current_holder.id ?? _null,
|
||||||
});
|
});
|
||||||
|
|
@ -4253,6 +4256,14 @@ export class CommandController extends Controller {
|
||||||
profile.isActive = true;
|
profile.isActive = true;
|
||||||
}
|
}
|
||||||
await this.profileRepository.save(profile);
|
await this.profileRepository.save(profile);
|
||||||
|
|
||||||
|
if (profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[profile.id],
|
||||||
|
"PROFILE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// update user attribute in keycloak
|
// update user attribute in keycloak
|
||||||
await updateUserAttributes(profile.keycloak ?? "", {
|
await updateUserAttributes(profile.keycloak ?? "", {
|
||||||
profileId: [profile.id],
|
profileId: [profile.id],
|
||||||
|
|
@ -4499,6 +4510,14 @@ export class CommandController extends Controller {
|
||||||
// profile.posLevelId = _null;
|
// profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await this.profileEmployeeRepository.save(profile);
|
await this.profileEmployeeRepository.save(profile);
|
||||||
|
|
||||||
|
if (profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[profile.id],
|
||||||
|
"PROFILE_EMPLOYEE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Task #2190
|
// Task #2190
|
||||||
if (code && ["C-PM-23", "C-PM-43"].includes(code)) {
|
if (code && ["C-PM-23", "C-PM-43"].includes(code)) {
|
||||||
let organizeName = "";
|
let organizeName = "";
|
||||||
|
|
@ -4714,6 +4733,13 @@ export class CommandController extends Controller {
|
||||||
profile.amount = item.amount ?? _null;
|
profile.amount = item.amount ?? _null;
|
||||||
profile.amountSpecial = item.amountSpecial ?? _null;
|
profile.amountSpecial = item.amountSpecial ?? _null;
|
||||||
await this.profileRepository.save(profile, { data: req });
|
await this.profileRepository.save(profile, { data: req });
|
||||||
|
|
||||||
|
if (profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[profile.id],
|
||||||
|
"PROFILE",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Object.assign(data, { ...item, ...meta });
|
Object.assign(data, { ...item, ...meta });
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
|
|
@ -5198,6 +5224,12 @@ export class CommandController extends Controller {
|
||||||
// _profile.posLevelId = _null;
|
// _profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await this.profileRepository.save(_profile);
|
await this.profileRepository.save(_profile);
|
||||||
|
if (_profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[_profile.id],
|
||||||
|
"PROFILE",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ลูกจ้าง
|
// ลูกจ้าง
|
||||||
|
|
@ -5375,6 +5407,12 @@ export class CommandController extends Controller {
|
||||||
// _profile.posLevelId = _null;
|
// _profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await this.profileEmployeeRepository.save(_profile);
|
await this.profileEmployeeRepository.save(_profile);
|
||||||
|
if (_profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[_profile.id],
|
||||||
|
"PROFILE_EMPLOYEE",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Task #2190
|
// Task #2190
|
||||||
|
|
@ -5706,6 +5744,13 @@ export class CommandController extends Controller {
|
||||||
// _profile.posLevelId = _null;
|
// _profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await this.profileEmployeeRepository.save(_profile);
|
await this.profileEmployeeRepository.save(_profile);
|
||||||
|
|
||||||
|
if (_profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[_profile.id],
|
||||||
|
"PROFILE_EMPLOYEE",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -6040,26 +6085,26 @@ export class CommandController extends Controller {
|
||||||
!profile.current_holders || profile.current_holders.length == 0
|
!profile.current_holders || profile.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
||||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
?.orgChild4 != null
|
?.orgChild4 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
|
? `${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) != null &&
|
||||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
?.orgChild3 != null
|
?.orgChild3 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
|
? `${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) != null &&
|
||||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
||||||
null &&
|
null &&
|
||||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
||||||
null &&
|
null &&
|
||||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
|
||||||
: null;
|
: null;
|
||||||
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
|
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
|
||||||
|
|
@ -6139,6 +6184,14 @@ export class CommandController extends Controller {
|
||||||
this.profileRepository.save(_profile),
|
this.profileRepository.save(_profile),
|
||||||
this.salaryRepo.save(profileSalary),
|
this.salaryRepo.save(profileSalary),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (profile.id) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[profile.id],
|
||||||
|
"PROFILE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
Object.assign(history, { ...profileSalary, id: undefined });
|
Object.assign(history, { ...profileSalary, id: undefined });
|
||||||
history.profileSalaryId = profileSalary.id;
|
history.profileSalaryId = profileSalary.id;
|
||||||
|
|
@ -6170,7 +6223,6 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6883,8 +6935,8 @@ export class CommandController extends Controller {
|
||||||
prefix: avatar,
|
prefix: avatar,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
})
|
})
|
||||||
.then(() => {})
|
.then(() => { })
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -7995,7 +8047,7 @@ export class CommandController extends Controller {
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
_command = res;
|
_command = res;
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
|
|
||||||
let issue =
|
let issue =
|
||||||
command.isBangkok == "OFFICE"
|
command.isBangkok == "OFFICE"
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import {
|
||||||
CreatePosMasterHistoryOfficer,
|
CreatePosMasterHistoryOfficer,
|
||||||
} from "../services/PositionService";
|
} from "../services/PositionService";
|
||||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||||
|
import { KeycloakAttributeService } from "../services/KeycloakAttributeService";
|
||||||
@Route("api/v1/org/employee/pos")
|
@Route("api/v1/org/employee/pos")
|
||||||
@Tags("Employee")
|
@Tags("Employee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -65,6 +66,7 @@ export class EmployeePositionController extends Controller {
|
||||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||||
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
||||||
|
private keycloakAttributeService = new KeycloakAttributeService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มตำแหน่งลูกจ้างประจำ
|
* API เพิ่มตำแหน่งลูกจ้างประจำ
|
||||||
|
|
@ -2435,6 +2437,12 @@ export class EmployeePositionController extends Controller {
|
||||||
// await this.profileRepository.save(profile);
|
// await this.profileRepository.save(profile);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
if (dataMaster.current_holderId) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[dataMaster.current_holderId],
|
||||||
|
"PROFILE_EMPLOYEE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await this.employeePosMasterRepository.update(id, {
|
await this.employeePosMasterRepository.update(id, {
|
||||||
isSit: false,
|
isSit: false,
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import permission from "../interfaces/permission";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import { CreatePosMasterHistoryEmployeeTemp } from "../services/PositionService";
|
import { CreatePosMasterHistoryEmployeeTemp } from "../services/PositionService";
|
||||||
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
||||||
|
import { KeycloakAttributeService } from "../services/KeycloakAttributeService";
|
||||||
@Route("api/v1/org/employee-temp/pos")
|
@Route("api/v1/org/employee-temp/pos")
|
||||||
@Tags("Employee")
|
@Tags("Employee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -65,6 +66,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||||
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
||||||
|
private keycloakAttributeService = new KeycloakAttributeService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มตำแหน่งลูกจ้างประจำ
|
* API เพิ่มตำแหน่งลูกจ้างประจำ
|
||||||
|
|
@ -2141,6 +2143,13 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if (dataMaster.current_holderId) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[dataMaster.current_holderId],
|
||||||
|
"PROFILE_EMPLOYEE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await this.employeeTempPosMasterRepository.update(id, {
|
await this.employeeTempPosMasterRepository.update(id, {
|
||||||
isSit: false,
|
isSit: false,
|
||||||
next_holderId: null,
|
next_holderId: null,
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import { Assign } from "../entities/Assign";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||||
import { CreatePosMasterHistoryOfficer } from "../services/PositionService";
|
import { CreatePosMasterHistoryOfficer } from "../services/PositionService";
|
||||||
|
import { KeycloakAttributeService } from "../services/KeycloakAttributeService";
|
||||||
@Route("api/v1/org/pos")
|
@Route("api/v1/org/pos")
|
||||||
@Tags("Position")
|
@Tags("Position")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -73,6 +74,7 @@ export class PositionController extends Controller {
|
||||||
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
||||||
private posMasterAssignRepo = AppDataSource.getRepository(PosMasterAssign);
|
private posMasterAssignRepo = AppDataSource.getRepository(PosMasterAssign);
|
||||||
private assignRepo = AppDataSource.getRepository(Assign);
|
private assignRepo = AppDataSource.getRepository(Assign);
|
||||||
|
private keycloakAttributeService = new KeycloakAttributeService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มตำแหน่ง
|
* API เพิ่มตำแหน่ง
|
||||||
|
|
@ -3868,6 +3870,13 @@ export class PositionController extends Controller {
|
||||||
await CreatePosMasterHistoryOfficer(dataMaster.id, request, "DELETE");
|
await CreatePosMasterHistoryOfficer(dataMaster.id, request, "DELETE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataMaster.current_holderId) {
|
||||||
|
await this.keycloakAttributeService.clearOrgDnaAttributes(
|
||||||
|
[dataMaster.current_holderId],
|
||||||
|
"PROFILE",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let _profileId: string = "";
|
let _profileId: string = "";
|
||||||
if (dataMaster?.current_holderId) {
|
if (dataMaster?.current_holderId) {
|
||||||
_profileId = dataMaster?.current_holderId;
|
_profileId = dataMaster?.current_holderId;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue