no message
This commit is contained in:
parent
ff49b53713
commit
c0bfd46fc3
4 changed files with 365 additions and 122 deletions
|
|
@ -1326,7 +1326,7 @@ export class CommandController extends Controller {
|
||||||
RemarkHorizontal: x.remarkHorizontal,
|
RemarkHorizontal: x.remarkHorizontal,
|
||||||
RemarkVertical: x.remarkVertical,
|
RemarkVertical: x.remarkVertical,
|
||||||
CommandYear: command.commandYear,
|
CommandYear: command.commandYear,
|
||||||
CommandExcecuteDate: command.commandExcecuteDate
|
CommandExcecuteDate: command.commandExcecuteDate,
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
|
@ -1658,8 +1658,8 @@ export class CommandController extends Controller {
|
||||||
},
|
},
|
||||||
select: ["orgRootId"],
|
select: ["orgRootId"],
|
||||||
});
|
});
|
||||||
let _posMaster : any
|
let _posMaster: any;
|
||||||
if(["C-PM-38", "C-PM-40"].includes(commandCode)) {
|
if (["C-PM-38", "C-PM-40"].includes(commandCode)) {
|
||||||
_posMaster = await this.posMasterRepository.find({
|
_posMaster = await this.posMasterRepository.find({
|
||||||
where: {
|
where: {
|
||||||
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
||||||
|
|
@ -1673,8 +1673,7 @@ export class CommandController extends Controller {
|
||||||
},
|
},
|
||||||
relations: ["current_holder", "orgRoot"],
|
relations: ["current_holder", "orgRoot"],
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_posMaster = await this.posMasterRepository.find({
|
_posMaster = await this.posMasterRepository.find({
|
||||||
where: {
|
where: {
|
||||||
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
||||||
|
|
@ -1686,7 +1685,7 @@ export class CommandController extends Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
_posMaster.map(async (item:any) => {
|
_posMaster.map(async (item: any) => {
|
||||||
const _commandSend = await this.commandSendRepository.findOne({
|
const _commandSend = await this.commandSendRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
commandId: command.id,
|
commandId: command.id,
|
||||||
|
|
@ -1710,14 +1709,16 @@ export class CommandController extends Controller {
|
||||||
commandSend.lastUpdateFullName = request.user.name;
|
commandSend.lastUpdateFullName = request.user.name;
|
||||||
commandSend.lastUpdatedAt = new Date();
|
commandSend.lastUpdatedAt = new Date();
|
||||||
await this.commandSendRepository.save(commandSend);
|
await this.commandSendRepository.save(commandSend);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const _posMasterNext = await this.posMasterRepository.find({
|
const _posMasterNext = await this.posMasterRepository.find({
|
||||||
where: {
|
where: {
|
||||||
orgRootId: In(requestBody.persons
|
orgRootId: In(
|
||||||
.filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "")
|
requestBody.persons
|
||||||
.map((x) => x.rootId)),
|
.filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "")
|
||||||
|
.map((x) => x.rootId),
|
||||||
|
),
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
current_holderId: Not(IsNull()),
|
current_holderId: Not(IsNull()),
|
||||||
|
|
@ -1952,7 +1953,7 @@ export class CommandController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||||
if (posMasterOld != null) posMasterOld.next_holderId = null;
|
// if (posMasterOld != null) posMasterOld.next_holderId = null;
|
||||||
|
|
||||||
const positionOld = await this.employeePositionRepository.findOne({
|
const positionOld = await this.employeePositionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1980,7 +1981,7 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
posMaster.current_holderId = item.profileId;
|
posMaster.current_holderId = item.profileId;
|
||||||
posMaster.next_holderId = item.profileId;
|
posMaster.next_holderId = null;
|
||||||
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
|
@ -2042,8 +2043,8 @@ export class CommandController extends Controller {
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
})
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
|
@ -2098,11 +2099,10 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
const returnWork = await checkReturnCommandType(String(item.commandId));
|
const returnWork = await checkReturnCommandType(String(item.commandId));
|
||||||
if (returnWork && item.isGovernment) {
|
if (returnWork && item.isGovernment) {
|
||||||
if (profile.keycloak != null ) {
|
if (profile.keycloak != null) {
|
||||||
const enableActive = await enableStatus(profile.keycloak, true);
|
const enableActive = await enableStatus(profile.keycloak, true);
|
||||||
if (!enableActive) throw new Error("Failed. Cannot change enable status.");
|
if (!enableActive) throw new Error("Failed. Cannot change enable status.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||||
firstName: profile.firstName,
|
firstName: profile.firstName,
|
||||||
lastName: profile.lastName,
|
lastName: profile.lastName,
|
||||||
|
|
@ -2163,8 +2163,8 @@ export class CommandController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileEmployeeRepository.findOne({
|
const profile = await this.profileEmployeeRepository.findOne({
|
||||||
where: {id: item.profileId},
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
|
@ -2258,10 +2258,10 @@ export class CommandController extends Controller {
|
||||||
) {
|
) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
|
@ -2282,7 +2282,7 @@ export class CommandController extends Controller {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
if(item.isLeave != undefined && item.isLeave == true) {
|
if (item.isLeave != undefined && item.isLeave == true) {
|
||||||
await removeProfileInOrganize(profile.id, "OFFICER");
|
await removeProfileInOrganize(profile.id, "OFFICER");
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
|
|
@ -2405,7 +2405,7 @@ export class CommandController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
relations: ["profileSalary","posLevel","posType","current_holders", "roleKeycloaks"],
|
relations: ["profileSalary", "posLevel", "posType", "current_holders", "roleKeycloaks"],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
|
|
@ -2417,17 +2417,17 @@ export class CommandController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where:{
|
where: {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
orgRevisionIsDraft: false
|
orgRevisionIsDraft: false,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
const shortName =
|
const shortName =
|
||||||
!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)?.orgChild4 !=
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
null
|
?.orgChild4 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
|
|
@ -2437,7 +2437,8 @@ export class CommandController extends Controller {
|
||||||
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)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
|
|
@ -2447,7 +2448,10 @@ export class CommandController extends Controller {
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null;
|
let position =
|
||||||
|
profile.current_holders
|
||||||
|
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
||||||
|
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
|
||||||
// ประวัติตำแหน่ง
|
// ประวัติตำแหน่ง
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalary();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -2459,7 +2463,7 @@ export class CommandController extends Controller {
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
positionType: profile.posType.posTypeName,
|
positionType: profile.posType.posTypeName,
|
||||||
positionLevel: profile.posLevel.posLevelName,
|
positionLevel: profile.posLevel.posLevelName,
|
||||||
posNo: shortName?shortName:"-",
|
posNo: shortName ? shortName : "-",
|
||||||
positionLine: position?.positionField ?? "-",
|
positionLine: position?.positionField ?? "-",
|
||||||
positionPathSide: position?.positionArea ?? "-",
|
positionPathSide: position?.positionArea ?? "-",
|
||||||
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
|
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
|
||||||
|
|
@ -2528,8 +2532,7 @@ export class CommandController extends Controller {
|
||||||
const exceptClear = await checkExceptCommandType(String(item.commandId));
|
const exceptClear = await checkExceptCommandType(String(item.commandId));
|
||||||
if (item.isLeave == true && !exceptClear) {
|
if (item.isLeave == true && !exceptClear) {
|
||||||
await removeProfileInOrganize(_profile.id, "OFFICER");
|
await removeProfileInOrganize(_profile.id, "OFFICER");
|
||||||
}
|
} else if (item.isLeave == true && exceptClear && _profile.keycloak != null) {
|
||||||
else if (item.isLeave == true && exceptClear && _profile.keycloak != null) {
|
|
||||||
const enableActive = await enableStatus(_profile.keycloak, false);
|
const enableActive = await enableStatus(_profile.keycloak, false);
|
||||||
if (!enableActive) throw new Error("Failed. Cannot change enable status.");
|
if (!enableActive) throw new Error("Failed. Cannot change enable status.");
|
||||||
_profile.isActive = false;
|
_profile.isActive = false;
|
||||||
|
|
@ -2596,18 +2599,18 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where:{
|
where: {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
orgRevisionIsDraft: false
|
orgRevisionIsDraft: false,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
const shortName =
|
const shortName =
|
||||||
!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)?.orgChild4 !=
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
null
|
?.orgChild4 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
|
|
@ -2617,7 +2620,8 @@ export class CommandController extends Controller {
|
||||||
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)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
|
|
@ -2627,7 +2631,10 @@ export class CommandController extends Controller {
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null;
|
let position =
|
||||||
|
profile.current_holders
|
||||||
|
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
||||||
|
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
|
||||||
// ประวัติตำแหน่ง
|
// ประวัติตำแหน่ง
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalary();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -2639,7 +2646,7 @@ export class CommandController extends Controller {
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
positionType: profile.posType.posTypeName,
|
positionType: profile.posType.posTypeName,
|
||||||
positionLevel: profile.posLevel.posLevelName,
|
positionLevel: profile.posLevel.posLevelName,
|
||||||
posNo: shortName?shortName:"-",
|
posNo: shortName ? shortName : "-",
|
||||||
positionLine: position?.positionField ?? "-",
|
positionLine: position?.positionField ?? "-",
|
||||||
positionPathSide: position?.positionArea ?? "-",
|
positionPathSide: position?.positionArea ?? "-",
|
||||||
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
|
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
|
||||||
|
|
@ -2669,11 +2676,13 @@ export class CommandController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const checkCommandType = await this.commandRepository.findOne({
|
const checkCommandType = await this.commandRepository.findOne({
|
||||||
where: { id: (body.data.length > 0 ? body.data[0].commandId?.toString() : "") },
|
where: { id: body.data.length > 0 ? body.data[0].commandId?.toString() : "" },
|
||||||
relations: ["commandType"]
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
if(checkCommandType?.commandType.code == "C-PM-11") {
|
if (checkCommandType?.commandType.code == "C-PM-11") {
|
||||||
const profile = await this.profileRepository.find({ where: { id: In(body.data.map(x => x.profileId)) } });
|
const profile = await this.profileRepository.find({
|
||||||
|
where: { id: In(body.data.map((x) => x.profileId)) },
|
||||||
|
});
|
||||||
const data = profile.map((x) => ({
|
const data = profile.map((x) => ({
|
||||||
...x,
|
...x,
|
||||||
isProbation: false,
|
isProbation: false,
|
||||||
|
|
@ -2704,7 +2713,14 @@ export class CommandController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
relations: ["profileSalary","posType","posLevel",'current_holders','current_holders.positions','current_holders.positions.posExecutive'],
|
relations: [
|
||||||
|
"profileSalary",
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"current_holders",
|
||||||
|
"current_holders.positions",
|
||||||
|
"current_holders.positions.posExecutive",
|
||||||
|
],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
|
|
@ -2717,7 +2733,7 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
const _profile = await this.profileRepository.findOne({
|
const _profile = await this.profileRepository.findOne({
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
});
|
});
|
||||||
if (!_profile) {
|
if (!_profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
|
|
@ -2732,17 +2748,17 @@ export class CommandController extends Controller {
|
||||||
_profile.lastUpdatedAt = new Date();
|
_profile.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where:{
|
where: {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
orgRevisionIsDraft: false
|
orgRevisionIsDraft: false,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
const shortName =
|
const shortName =
|
||||||
!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)?.orgChild4 !=
|
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
||||||
null
|
?.orgChild4 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
|
|
@ -2752,7 +2768,8 @@ export class CommandController extends Controller {
|
||||||
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)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: 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)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
|
|
@ -2762,7 +2779,10 @@ export class CommandController extends Controller {
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null;
|
let position =
|
||||||
|
profile.current_holders
|
||||||
|
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
||||||
|
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: item.profileId,
|
profileId: item.profileId,
|
||||||
date: item.date,
|
date: item.date,
|
||||||
|
|
@ -2798,23 +2818,23 @@ export class CommandController extends Controller {
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
if (clearProfile) {
|
if (clearProfile) {
|
||||||
if (_profile.keycloak != null) {
|
if (_profile.keycloak != null) {
|
||||||
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
||||||
if (delUserKeycloak) _profile.keycloak = _null;
|
if (delUserKeycloak) _profile.keycloak = _null;
|
||||||
_profile.roleKeycloaks = [];
|
_profile.roleKeycloaks = [];
|
||||||
}
|
}
|
||||||
_profile.position = _null;
|
_profile.position = _null;
|
||||||
_profile.posTypeId = _null;
|
_profile.posTypeId = _null;
|
||||||
_profile.posLevelId = _null;
|
_profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepository.save(_profile),
|
this.profileRepository.save(_profile),
|
||||||
this.salaryRepo.save(profileSalary),
|
this.salaryRepo.save(profileSalary),
|
||||||
]);
|
]);
|
||||||
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;
|
||||||
await this.salaryHistoryRepo.save(history);
|
await this.salaryHistoryRepo.save(history);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -2840,7 +2860,7 @@ export class CommandController extends Controller {
|
||||||
) {
|
) {
|
||||||
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
||||||
where: { name: Like("USER") },
|
where: { name: Like("USER") },
|
||||||
});
|
});
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const before = null;
|
const before = null;
|
||||||
|
|
@ -2870,7 +2890,7 @@ export class CommandController extends Controller {
|
||||||
|
|
||||||
let profile: any = await this.profileRepository.findOne({
|
let profile: any = await this.profileRepository.findOne({
|
||||||
where: { citizenId: item.bodyProfile.citizenId },
|
where: { citizenId: item.bodyProfile.citizenId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
profile = Object.assign({ ...item.bodyProfile, ...meta });
|
profile = Object.assign({ ...item.bodyProfile, ...meta });
|
||||||
|
|
@ -2903,7 +2923,7 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
if (!result) throw new Error("Failed. Cannot set user's role.");
|
if (!result) throw new Error("Failed. Cannot set user's role.");
|
||||||
profile.keycloak = userKeycloakId;
|
profile.keycloak = userKeycloakId;
|
||||||
profile.roleKeycloaks = roleKeycloak ? [roleKeycloak] : []
|
profile.roleKeycloaks = roleKeycloak ? [roleKeycloak] : [];
|
||||||
profile.email = item.bodyProfile.email;
|
profile.email = item.bodyProfile.email;
|
||||||
await this.profileRepository.save(profile);
|
await this.profileRepository.save(profile);
|
||||||
setLogDataDiff(req, { before, after: profile });
|
setLogDataDiff(req, { before, after: profile });
|
||||||
|
|
@ -3061,7 +3081,7 @@ export class CommandController extends Controller {
|
||||||
await this.posMasterRepository.save(data);
|
await this.posMasterRepository.save(data);
|
||||||
if (posMasters && posMasters.length > 0) {
|
if (posMasters && posMasters.length > 0) {
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { id: posMasters[0].orgRevisionId }
|
where: { id: posMasters[0].orgRevisionId },
|
||||||
});
|
});
|
||||||
if (orgRevision != null && orgRevision.isLock == false) {
|
if (orgRevision != null && orgRevision.isLock == false) {
|
||||||
await this.orgRevisionRepo.update(orgRevision.id, {
|
await this.orgRevisionRepo.update(orgRevision.id, {
|
||||||
|
|
@ -3114,8 +3134,8 @@ export class CommandController extends Controller {
|
||||||
body.refIds.map(async (item) => {
|
body.refIds.map(async (item) => {
|
||||||
const profile = await this.profileEmployeeRepository.findOne({
|
const profile = await this.profileEmployeeRepository.findOne({
|
||||||
where: { id: item.refId },
|
where: { id: item.refId },
|
||||||
relations: ["roleKeycloaks"]
|
relations: ["roleKeycloaks"],
|
||||||
})
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
|
@ -3172,7 +3192,7 @@ export class CommandController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||||
if (posMasterOld != null) posMasterOld.next_holderId = null;
|
// if (posMasterOld != null) posMasterOld.next_holderId = null;
|
||||||
|
|
||||||
const positionOld = await this.employeePositionRepository.findOne({
|
const positionOld = await this.employeePositionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -3200,7 +3220,7 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
posMaster.current_holderId = profile.id;
|
posMaster.current_holderId = profile.id;
|
||||||
posMaster.next_holderId = profile.id;
|
posMaster.next_holderId = null;
|
||||||
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
|
@ -3212,7 +3232,6 @@ export class CommandController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (positionNew != null) {
|
if (positionNew != null) {
|
||||||
|
|
||||||
// Create Keycloak
|
// Create Keycloak
|
||||||
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||||
firstName: profile.firstName,
|
firstName: profile.firstName,
|
||||||
|
|
@ -3236,7 +3255,7 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
if (!result) throw new Error("Failed. Cannot set user's role.");
|
if (!result) throw new Error("Failed. Cannot set user's role.");
|
||||||
profile.keycloak = userKeycloakId;
|
profile.keycloak = userKeycloakId;
|
||||||
profile.roleKeycloaks = roleKeycloak ? [roleKeycloak] : []
|
profile.roleKeycloaks = roleKeycloak ? [roleKeycloak] : [];
|
||||||
// End Create Keycloak
|
// End Create Keycloak
|
||||||
|
|
||||||
positionNew.positionIsSelected = true;
|
positionNew.positionIsSelected = true;
|
||||||
|
|
@ -3404,13 +3423,13 @@ export class CommandController extends Controller {
|
||||||
oc:
|
oc:
|
||||||
/*(posMasterAct.posMasterChild?.current_holder?.position ?? "-") +
|
/*(posMasterAct.posMasterChild?.current_holder?.position ?? "-") +
|
||||||
"/" +*/
|
"/" +*/
|
||||||
(_organization ?? "-"),
|
_organization ?? "-",
|
||||||
postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? "-",
|
postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? "-",
|
||||||
poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? "-",
|
poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? "-",
|
||||||
organizationNew:
|
organizationNew:
|
||||||
/*(posMasterAct.posMaster?.current_holder?.position ?? "-") +
|
/*(posMasterAct.posMaster?.current_holder?.position ?? "-") +
|
||||||
"/" +*/
|
"/" +*/
|
||||||
(_organizationNew ?? "-"),
|
_organizationNew ?? "-",
|
||||||
// date: Extension.ToThaiShortDate_noPrefix(new Date()),
|
// date: Extension.ToThaiShortDate_noPrefix(new Date()),
|
||||||
dateStart: "-",
|
dateStart: "-",
|
||||||
dateEnd: "-",
|
dateEnd: "-",
|
||||||
|
|
@ -3483,7 +3502,7 @@ export class CommandController extends Controller {
|
||||||
posMasterId: posMaster.id,
|
posMasterId: posMaster.id,
|
||||||
positionIsSelected: true,
|
positionIsSelected: true,
|
||||||
},
|
},
|
||||||
relations: ["posType", "posLevel"]
|
relations: ["posType", "posLevel"],
|
||||||
});
|
});
|
||||||
const dest_item = await this.salaryRepo.findOne({
|
const dest_item = await this.salaryRepo.findOne({
|
||||||
where: { profileId: profile?.id },
|
where: { profileId: profile?.id },
|
||||||
|
|
@ -3567,10 +3586,13 @@ export class CommandController extends Controller {
|
||||||
const revisionId = data[0].orgRevisionId;
|
const revisionId = data[0].orgRevisionId;
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { id: revisionId },
|
where: { id: revisionId },
|
||||||
relations: ["posMasters"]
|
relations: ["posMasters"],
|
||||||
});
|
});
|
||||||
if (orgRevision != null && !["REPORT"].includes(
|
if (
|
||||||
orgRevision.posMasters.find(x => x.statusReport === "REPORT")?.statusReport || "")
|
orgRevision != null &&
|
||||||
|
!["REPORT"].includes(
|
||||||
|
orgRevision.posMasters.find((x) => x.statusReport === "REPORT")?.statusReport || "",
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
await this.orgRevisionRepo.update(orgRevision.id, {
|
await this.orgRevisionRepo.update(orgRevision.id, {
|
||||||
isLock: false,
|
isLock: false,
|
||||||
|
|
|
||||||
|
|
@ -2122,7 +2122,7 @@ export class EmployeePositionController extends Controller {
|
||||||
|
|
||||||
dataMaster.isSit = requestBody.isSit;
|
dataMaster.isSit = requestBody.isSit;
|
||||||
dataMaster.current_holderId = requestBody.profileId;
|
dataMaster.current_holderId = requestBody.profileId;
|
||||||
dataMaster.next_holderId = requestBody.profileId;
|
// dataMaster.next_holderId = requestBody.profileId;
|
||||||
await this.employeePosMasterRepository.save(dataMaster);
|
await this.employeePosMasterRepository.save(dataMaster);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -2242,7 +2242,7 @@ export class EmployeePositionController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||||
if (posMasterOld != null) posMasterOld.next_holderId = null;
|
// if (posMasterOld != null) posMasterOld.next_holderId = null;
|
||||||
|
|
||||||
const positionOld = await this.employeePositionRepository.findOne({
|
const positionOld = await this.employeePositionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -2276,7 +2276,7 @@ export class EmployeePositionController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
|
|
||||||
posMaster.current_holderId = body.profileId;
|
posMaster.current_holderId = body.profileId;
|
||||||
posMaster.next_holderId = body.profileId;
|
// posMaster.next_holderId = body.profileId;
|
||||||
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import permission from "../interfaces/permission";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
@Route("api/v1/org/pos")
|
@Route("api/v1/org/pos")
|
||||||
@Tags("Position")
|
@Tags("Position")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -56,8 +57,10 @@ export class PositionController extends Controller {
|
||||||
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||||
private posDictRepository = AppDataSource.getRepository(PosDict);
|
private posDictRepository = AppDataSource.getRepository(PosDict);
|
||||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||||
|
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
private positionRepository = AppDataSource.getRepository(Position);
|
private positionRepository = AppDataSource.getRepository(Position);
|
||||||
private profileRepository = AppDataSource.getRepository(Profile);
|
private profileRepository = AppDataSource.getRepository(Profile);
|
||||||
|
private profileEmployeeRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||||
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
||||||
|
|
@ -3587,6 +3590,7 @@ export class PositionController extends Controller {
|
||||||
.leftJoinAndSelect("positions.posType", "posType")
|
.leftJoinAndSelect("positions.posType", "posType")
|
||||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
|
.andWhere("posMaster.next_holderId IS NULL")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||||
|
|
@ -3841,6 +3845,7 @@ export class PositionController extends Controller {
|
||||||
.leftJoinAndSelect("positions.posType", "posType")
|
.leftJoinAndSelect("positions.posType", "posType")
|
||||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
|
.andWhere("posMaster.next_holderId IS NULL")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||||
|
|
@ -4799,4 +4804,218 @@ export class PositionController extends Controller {
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("officer/master/book")
|
||||||
|
async posMasterBookOfficer(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
profileId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
const profile = await this.profileRepository.findOne({
|
||||||
|
where: { id: requestBody.profileId },
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||||
|
|
||||||
|
posMaster.next_holderId = requestBody.profileId;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("officer/master/clear")
|
||||||
|
async posMasterClearOfficer(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMaster.next_holderId = null;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("employee/master/book")
|
||||||
|
async posMasterBookEmployee(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
profileId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
const profile = await this.profileEmployeeRepository.findOne({
|
||||||
|
where: { id: requestBody.profileId },
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||||
|
|
||||||
|
posMaster.next_holderId = requestBody.profileId;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("employee/master/clear")
|
||||||
|
async posMasterClearEmployee(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMaster.next_holderId = null;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("officer/master-old/book")
|
||||||
|
async posMasterOldBookOfficer(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
posMasterOldId: string;
|
||||||
|
profileId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
const profile = await this.profileRepository.findOne({
|
||||||
|
where: { id: requestBody.profileId },
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||||
|
|
||||||
|
posMaster.next_holderId = requestBody.profileId;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
if (requestBody.posMasterOldId != null) {
|
||||||
|
const posMasterOld = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterOldId },
|
||||||
|
});
|
||||||
|
if (!posMasterOld) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMasterOld.next_holderId = null;
|
||||||
|
posMasterOld.lastUpdateUserId = request.user.sub;
|
||||||
|
posMasterOld.lastUpdateFullName = request.user.name;
|
||||||
|
posMasterOld.lastUpdatedAt = new Date();
|
||||||
|
await this.posMasterRepository.save(posMasterOld);
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("employee/master-old/book")
|
||||||
|
async posMasterOldBookEmployee(
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
posMasterId: string;
|
||||||
|
posMasterOldId: string;
|
||||||
|
profileId: string;
|
||||||
|
},
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterId },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
const profile = await this.profileEmployeeRepository.findOne({
|
||||||
|
where: { id: requestBody.profileId },
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||||
|
|
||||||
|
posMaster.next_holderId = requestBody.profileId;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
if (requestBody.posMasterOldId != null) {
|
||||||
|
const posMasterOld = await this.employeePosMasterRepository.findOne({
|
||||||
|
where: { id: requestBody.posMasterOldId },
|
||||||
|
});
|
||||||
|
if (!posMasterOld) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMasterOld.next_holderId = null;
|
||||||
|
posMasterOld.lastUpdateUserId = request.user.sub;
|
||||||
|
posMasterOld.lastUpdateFullName = request.user.name;
|
||||||
|
posMasterOld.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(posMasterOld);
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -231,20 +231,23 @@ export class ProfileEmployeeController extends Controller {
|
||||||
where: { profileEmployeeId: id },
|
where: { profileEmployeeId: id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
const Education = educations && educations.length > 0
|
const Education =
|
||||||
? educations.map((item) => ({
|
educations && educations.length > 0
|
||||||
institute: item.institute ? item.institute : "-",
|
? educations.map((item) => ({
|
||||||
date:
|
institute: item.institute ? item.institute : "-",
|
||||||
item.startDate && item.endDate
|
date:
|
||||||
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
item.startDate && item.endDate
|
||||||
: "-",
|
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
|
||||||
degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
|
: "-",
|
||||||
}))
|
degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
|
||||||
: [{
|
}))
|
||||||
institute: "-",
|
: [
|
||||||
date: "-",
|
{
|
||||||
degree: "-",
|
institute: "-",
|
||||||
}]
|
date: "-",
|
||||||
|
degree: "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const mapData = {
|
const mapData = {
|
||||||
// Id: profile.id,
|
// Id: profile.id,
|
||||||
|
|
@ -1985,8 +1988,7 @@ 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,
|
||||||
salary:
|
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||||
profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
|
||||||
};
|
};
|
||||||
return new HttpSuccess(_profile);
|
return new HttpSuccess(_profile);
|
||||||
}
|
}
|
||||||
|
|
@ -3856,15 +3858,15 @@ export class ProfileEmployeeController extends Controller {
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
"profileSalary",
|
"profileSalary",
|
||||||
"profileEducations"
|
"profileEducations",
|
||||||
],
|
],
|
||||||
order: {
|
order: {
|
||||||
// profileSalary: {
|
// profileSalary: {
|
||||||
// order: "DESC",
|
// order: "DESC",
|
||||||
// },
|
// },
|
||||||
profileEducations: {
|
profileEducations: {
|
||||||
createdAt: "DESC"
|
createdAt: "DESC",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
|
|
@ -3986,11 +3988,11 @@ export class ProfileEmployeeController extends Controller {
|
||||||
node: null,
|
node: null,
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
posNo: shortName,
|
posNo: shortName,
|
||||||
salary:
|
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
||||||
profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
|
education:
|
||||||
education: profile && profile.profileEducations.length > 0
|
profile && profile.profileEducations.length > 0
|
||||||
? `${profile.profileEducations[0].degree ?? ""}-${profile.profileEducations[0].field ?? ""}`
|
? `${profile.profileEducations[0].degree ?? ""}-${profile.profileEducations[0].field ?? ""}`
|
||||||
: "-"
|
: "-",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_profile.child4Id != null) {
|
if (_profile.child4Id != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue