test เพิ่มฟังก์ชั่นให้ยิงไประบบ exprofile #2190
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
This commit is contained in:
parent
38e2ec6586
commit
78778e0eb0
6 changed files with 510 additions and 152 deletions
|
|
@ -97,6 +97,7 @@ import {
|
||||||
CreatePosMasterHistoryEmployeeTemp,
|
CreatePosMasterHistoryEmployeeTemp,
|
||||||
CreatePosMasterHistoryOfficer,
|
CreatePosMasterHistoryOfficer,
|
||||||
} from "../services/PositionService";
|
} from "../services/PositionService";
|
||||||
|
import { PostRetireToExprofile } from "./ExRetirementController";
|
||||||
@Route("api/v1/org/command")
|
@Route("api/v1/org/command")
|
||||||
@Tags("Command")
|
@Tags("Command")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -3798,7 +3799,12 @@ 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"],
|
||||||
|
relations: {
|
||||||
|
roleKeycloaks: true,
|
||||||
|
posType: true ,
|
||||||
|
posLevel: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
|
|
@ -3866,14 +3872,30 @@ export class CommandController extends Controller {
|
||||||
const curRevision = await this.orgRevisionRepo.findOne({
|
const curRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
});
|
});
|
||||||
|
let orgRootRef = null;
|
||||||
|
let orgChild1Ref = null;
|
||||||
|
let orgChild2Ref = null;
|
||||||
|
let orgChild3Ref = null;
|
||||||
|
let orgChild4Ref = null;
|
||||||
if (curRevision) {
|
if (curRevision) {
|
||||||
const curPosMaster = await this.posMasterRepository.findOne({
|
const curPosMaster = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
current_holderId: profile.id,
|
current_holderId: profile.id,
|
||||||
orgRevisionId: curRevision.id,
|
orgRevisionId: curRevision.id,
|
||||||
},
|
},
|
||||||
|
relations:{
|
||||||
|
orgRoot: true,
|
||||||
|
orgChild1: true,
|
||||||
|
orgChild2: true,
|
||||||
|
orgChild3: true,
|
||||||
|
orgChild4: true,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
orgRootRef = curPosMaster?.orgRoot ?? null;
|
||||||
|
orgChild1Ref = curPosMaster?.orgChild1 ?? null;
|
||||||
|
orgChild2Ref = curPosMaster?.orgChild2 ?? null;
|
||||||
|
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
|
||||||
|
orgChild4Ref = curPosMaster?.orgChild4 ?? null;
|
||||||
if (curPosMaster && clearProfile.LeaveType != "RETIRE_OUT_EMP") {
|
if (curPosMaster && clearProfile.LeaveType != "RETIRE_OUT_EMP") {
|
||||||
await CreatePosMasterHistoryOfficer(curPosMaster.id, req, "DELETE");
|
await CreatePosMasterHistoryOfficer(curPosMaster.id, req, "DELETE");
|
||||||
}
|
}
|
||||||
|
|
@ -4045,6 +4067,44 @@ export class CommandController extends Controller {
|
||||||
profile.isActive = true;
|
profile.isActive = true;
|
||||||
}
|
}
|
||||||
await this.profileRepository.save(profile);
|
await this.profileRepository.save(profile);
|
||||||
|
// Task #2190
|
||||||
|
if (code && ["C-PM-17", "C-PM-18"].includes(code)) {
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// item.commandDateAffect?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// profile.posLevel?.posLevelName ?? "",
|
||||||
|
// item.commandDateAffect ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// clearProfile.retireTypeName ?? "",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -4138,7 +4198,12 @@ export class CommandController extends Controller {
|
||||||
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"],
|
||||||
|
relations: {
|
||||||
|
roleKeycloaks: true,
|
||||||
|
posType: true ,
|
||||||
|
posLevel: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
|
@ -4204,6 +4269,35 @@ export class CommandController extends Controller {
|
||||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
|
const curRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
|
});
|
||||||
|
let orgRootRef = null;
|
||||||
|
let orgChild1Ref = null;
|
||||||
|
let orgChild2Ref = null;
|
||||||
|
let orgChild3Ref = null;
|
||||||
|
let orgChild4Ref = null;
|
||||||
|
if (curRevision) {
|
||||||
|
const curPosMaster = await this.employeePosMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
current_holderId: profile.id,
|
||||||
|
orgRevisionId: curRevision.id,
|
||||||
|
},
|
||||||
|
relations:{
|
||||||
|
orgRoot: true,
|
||||||
|
orgChild1: true,
|
||||||
|
orgChild2: true,
|
||||||
|
orgChild3: true,
|
||||||
|
orgChild4: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
orgRootRef = curPosMaster?.orgRoot ?? null;
|
||||||
|
orgChild1Ref = curPosMaster?.orgChild1 ?? null;
|
||||||
|
orgChild2Ref = curPosMaster?.orgChild2 ?? null;
|
||||||
|
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
|
||||||
|
orgChild4Ref = curPosMaster?.orgChild4 ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
if (clearProfile.status) {
|
if (clearProfile.status) {
|
||||||
if (profile.keycloak != null) {
|
if (profile.keycloak != null) {
|
||||||
const delUserKeycloak = await deleteUser(profile.keycloak);
|
const delUserKeycloak = await deleteUser(profile.keycloak);
|
||||||
|
|
@ -4224,6 +4318,44 @@ export class CommandController extends Controller {
|
||||||
// profile.posLevelId = _null;
|
// profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
await this.profileEmployeeRepository.save(profile);
|
await this.profileEmployeeRepository.save(profile);
|
||||||
|
// Task #2190
|
||||||
|
if (code && ["C-PM-23", "C-PM-43"].includes(code)) {
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// item.commandDateAffect?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
||||||
|
// item.commandDateAffect ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// clearProfile.retireTypeName ?? "",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -4320,7 +4452,12 @@ export class CommandController extends Controller {
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile: any = await this.profileRepository.findOne({
|
const profile: any = await this.profileRepository.findOne({
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"],
|
// relations: ["roleKeycloaks"],
|
||||||
|
relations: {
|
||||||
|
roleKeycloaks: true,
|
||||||
|
posType: true,
|
||||||
|
posLevel: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
|
|
@ -4333,10 +4470,22 @@ export class CommandController extends Controller {
|
||||||
orgRevisionIsDraft: false,
|
orgRevisionIsDraft: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
relations: ["orgRevision"],
|
relations: {
|
||||||
|
orgRevision: true,
|
||||||
|
orgRoot: true,
|
||||||
|
orgChild1: true,
|
||||||
|
orgChild2: true,
|
||||||
|
orgChild3: true,
|
||||||
|
orgChild4: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const orgRevisionRef = posMaster ? posMaster.id : null;
|
const orgRevisionRef = posMaster ? posMaster.id : null;
|
||||||
|
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
||||||
|
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
||||||
|
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
||||||
|
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
||||||
|
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
||||||
|
|
||||||
//ลบตำแหน่งที่รักษาการแทน
|
//ลบตำแหน่งที่รักษาการแทน
|
||||||
const code = _command?.commandType?.code;
|
const code = _command?.commandType?.code;
|
||||||
|
|
@ -4405,15 +4554,14 @@ export class CommandController extends Controller {
|
||||||
history.profileSalaryId = data.id;
|
history.profileSalaryId = data.id;
|
||||||
await this.salaryHistoryRepo.save(history, { data: req });
|
await this.salaryHistoryRepo.save(history, { data: req });
|
||||||
|
|
||||||
if (item.commandId) {
|
if (_command) {
|
||||||
|
/*
|
||||||
const command = await this.commandRepository.findOne({
|
const command = await this.commandRepository.findOne({
|
||||||
where: { id: item.commandId },
|
where: { id: item.commandId },
|
||||||
relations: ["commandType"],
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
if (
|
*/
|
||||||
command != null &&
|
if (["C-PM-15", "C-PM-16"].includes(_command.commandType.code)) {
|
||||||
(command.commandType.code == "C-PM-15" || command.commandType.code == "C-PM-16")
|
|
||||||
) {
|
|
||||||
// ประวัติคำสั่งให้ช่วยราชการ
|
// ประวัติคำสั่งให้ช่วยราชการ
|
||||||
const dataAssis = new ProfileAssistance();
|
const dataAssis = new ProfileAssistance();
|
||||||
|
|
||||||
|
|
@ -4433,7 +4581,7 @@ export class CommandController extends Controller {
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
status: command.commandType.code == "C-PM-15" ? "PENDING" : "DONE",
|
status: _command.commandType.code == "C-PM-15" ? "PENDING" : "DONE",
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(dataAssis, metaAssis);
|
Object.assign(dataAssis, metaAssis);
|
||||||
|
|
@ -4444,6 +4592,44 @@ export class CommandController extends Controller {
|
||||||
historyAssis.profileAssistanceId = dataAssis.id;
|
historyAssis.profileAssistanceId = dataAssis.id;
|
||||||
await this.assistanceHistoryRepository.save(historyAssis);
|
await this.assistanceHistoryRepository.save(historyAssis);
|
||||||
}
|
}
|
||||||
|
// Task #2190
|
||||||
|
else if (_command.commandType.code == "C-PM-13") {
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// item.commandDateAffect?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// profile.posLevel?.posLevelName ?? "",
|
||||||
|
// item.commandDateAffect ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// clearProfile.retireTypeName ?? "",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -4656,10 +4842,25 @@ export class CommandController extends Controller {
|
||||||
if (item.commandYear) {
|
if (item.commandYear) {
|
||||||
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
||||||
}
|
}
|
||||||
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
let orgRootRef = null;
|
||||||
|
let orgChild1Ref = null;
|
||||||
|
let orgChild2Ref = null;
|
||||||
|
let orgChild3Ref = null;
|
||||||
|
let orgChild4Ref = null;
|
||||||
|
let profile;
|
||||||
|
let isEmployee:boolean = false;
|
||||||
|
let retireTypeName:string = "";
|
||||||
|
// ขรก.
|
||||||
if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") {
|
if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") {
|
||||||
const profile = await this.profileRepository.findOne({
|
profile = await this.profileRepository.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"posLevel",
|
"posLevel",
|
||||||
"posType",
|
"posType",
|
||||||
"current_holders",
|
"current_holders",
|
||||||
|
|
@ -4673,63 +4874,35 @@ export class CommandController extends Controller {
|
||||||
"roleKeycloaks",
|
"roleKeycloaks",
|
||||||
],
|
],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
// order: {
|
||||||
profileSalary: {
|
// profileSalary: {
|
||||||
order: "DESC",
|
// order: "DESC",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
const lastSalary = await this.salaryRepo.findOne({
|
||||||
|
where: { profileId: item.profileId },
|
||||||
|
select: ["order"],
|
||||||
|
order: { order: "DESC" },
|
||||||
|
});
|
||||||
|
const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
|
||||||
//ลบตำแหน่งที่รักษาการแทน
|
//ลบตำแหน่งที่รักษาการแทน
|
||||||
const code = _command?.commandType?.code;
|
const code = _command?.commandType?.code;
|
||||||
if (code && ["C-PM-19", "C-PM-20"].includes(code)) {
|
if (code && ["C-PM-19", "C-PM-20"].includes(code)) {
|
||||||
removePostMasterAct(profile.id);
|
removePostMasterAct(profile.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
|
||||||
where: {
|
|
||||||
orgRevisionIsCurrent: true,
|
|
||||||
orgRevisionIsDraft: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const orgRevisionRef =
|
const orgRevisionRef =
|
||||||
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
||||||
// const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
||||||
// const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
||||||
// const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
||||||
// const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
||||||
// const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
||||||
// const shortName =
|
|
||||||
// !profile.current_holders || profile.current_holders.length == 0
|
|
||||||
// ? null
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild4 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild3 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild2 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild1 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgRoot != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
|
|
||||||
// : null;
|
|
||||||
// const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
|
|
||||||
let position =
|
let position =
|
||||||
profile.current_holders
|
profile.current_holders
|
||||||
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
.filter((x) => x.orgRevisionId == orgRevision?.id)[0]
|
||||||
|
|
@ -4750,12 +4923,13 @@ export class CommandController extends Controller {
|
||||||
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||||
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
||||||
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||||
order:
|
// order:
|
||||||
profile.profileSalary.length >= 0
|
// profile.profileSalary.length >= 0
|
||||||
? profile.profileSalary.length > 0
|
// ? profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[0].order + 1
|
// ? profile.profileSalary[0].order + 1
|
||||||
: 1
|
// : 1
|
||||||
: null,
|
// : null,
|
||||||
|
order: nextOrder,
|
||||||
orgRoot: item.orgRoot,
|
orgRoot: item.orgRoot,
|
||||||
orgChild1: item.orgChild1,
|
orgChild1: item.orgChild1,
|
||||||
orgChild2: item.orgChild2,
|
orgChild2: item.orgChild2,
|
||||||
|
|
@ -4845,6 +5019,7 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
if (clearProfile.status) {
|
if (clearProfile.status) {
|
||||||
|
retireTypeName = clearProfile.retireTypeName ?? "";
|
||||||
if (_profile.keycloak != null) {
|
if (_profile.keycloak != null) {
|
||||||
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
||||||
if (delUserKeycloak) {
|
if (delUserKeycloak) {
|
||||||
|
|
@ -4865,10 +5040,13 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
await this.profileRepository.save(_profile);
|
await this.profileRepository.save(_profile);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
const profile = await this.profileEmployeeRepository.findOne({
|
// ลูกจ้าง
|
||||||
|
else {
|
||||||
|
isEmployee = true;
|
||||||
|
profile = await this.profileEmployeeRepository.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"posLevel",
|
"posLevel",
|
||||||
"posType",
|
"posType",
|
||||||
"current_holders",
|
"current_holders",
|
||||||
|
|
@ -4880,60 +5058,29 @@ export class CommandController extends Controller {
|
||||||
"roleKeycloaks",
|
"roleKeycloaks",
|
||||||
],
|
],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
// order: {
|
||||||
profileSalary: {
|
// profileSalary: {
|
||||||
order: "DESC",
|
// order: "DESC",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
// const orgRevision = await this.orgRevisionRepo.findOne({
|
const lastSalary = await this.salaryRepo.findOne({
|
||||||
// where: {
|
where: { profileEmployeeId: item.profileId },
|
||||||
// orgRevisionIsCurrent: true,
|
select: ["order"],
|
||||||
// orgRevisionIsDraft: false,
|
order: { order: "DESC" },
|
||||||
// },
|
});
|
||||||
// });
|
const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
|
||||||
// const orgRevisionRef =
|
const orgRevisionRef =
|
||||||
// profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
||||||
// const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
||||||
// const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
||||||
// const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
||||||
// const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
|
||||||
// const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
|
||||||
// const shortName =
|
|
||||||
// !profile.current_holders || profile.current_holders.length == 0
|
|
||||||
// ? null
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild4 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild3 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild2 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgChild1 != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
|
|
||||||
// : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
|
|
||||||
// null &&
|
|
||||||
// profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
|
|
||||||
// ?.orgRoot != null
|
|
||||||
// ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
|
|
||||||
// : null;
|
|
||||||
// const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
|
|
||||||
// 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();
|
||||||
data.posNumCodeSit = _posNumCodeSit;
|
data.posNumCodeSit = _posNumCodeSit;
|
||||||
|
|
@ -4951,12 +5098,13 @@ export class CommandController extends Controller {
|
||||||
amount: item.amount ? item.amount : null,
|
amount: item.amount ? item.amount : null,
|
||||||
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||||
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||||
order:
|
// order:
|
||||||
profile.profileSalary.length >= 0
|
// profile.profileSalary.length >= 0
|
||||||
? profile.profileSalary.length > 0
|
// ? profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[0].order + 1
|
// ? profile.profileSalary[0].order + 1
|
||||||
: 1
|
// : 1
|
||||||
: null,
|
// : null,
|
||||||
|
order: nextOrder,
|
||||||
orgRoot: item.orgRoot,
|
orgRoot: item.orgRoot,
|
||||||
orgChild1: item.orgChild1,
|
orgChild1: item.orgChild1,
|
||||||
orgChild2: item.orgChild2,
|
orgChild2: item.orgChild2,
|
||||||
|
|
@ -5048,6 +5196,7 @@ export class CommandController extends Controller {
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
if (clearProfile.status) {
|
if (clearProfile.status) {
|
||||||
|
retireTypeName = clearProfile.retireTypeName ?? "";
|
||||||
if (_profile.keycloak != null) {
|
if (_profile.keycloak != null) {
|
||||||
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
const delUserKeycloak = await deleteUser(_profile.keycloak);
|
||||||
if (delUserKeycloak) {
|
if (delUserKeycloak) {
|
||||||
|
|
@ -5069,6 +5218,47 @@ export class CommandController extends Controller {
|
||||||
await this.profileEmployeeRepository.save(_profile);
|
await this.profileEmployeeRepository.save(_profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Task #2190
|
||||||
|
if (_command && ["C-PM-19", "C-PM-20"].includes(_command.commandType.code)) {
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
let _posLevelName: string = !isEmployee
|
||||||
|
? `${profile.posLevel?.posLevelName}`
|
||||||
|
: `${profile.posType?.posTypeName} ${profile.posLevel?.posLevelName}`;
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// item.commandDateAffect?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// _posLevelName,
|
||||||
|
// item.commandDateAffect ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// retireTypeName,
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -5158,7 +5348,7 @@ export class CommandController extends Controller {
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile = await this.profileEmployeeRepository.findOne({
|
const profile = await this.profileEmployeeRepository.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"posLevel",
|
"posLevel",
|
||||||
"posType",
|
"posType",
|
||||||
"current_holders",
|
"current_holders",
|
||||||
|
|
@ -5170,15 +5360,21 @@ export class CommandController extends Controller {
|
||||||
"roleKeycloaks",
|
"roleKeycloaks",
|
||||||
],
|
],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
// order: {
|
||||||
profileSalary: {
|
// profileSalary: {
|
||||||
order: "DESC",
|
// order: "DESC",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
const lastSalary = await this.salaryRepo.findOne({
|
||||||
|
where: { profileEmployeeId: item.profileId },
|
||||||
|
select: ["order"],
|
||||||
|
order: { order: "DESC" },
|
||||||
|
});
|
||||||
|
const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
|
||||||
let _commandYear = item.commandYear;
|
let _commandYear = item.commandYear;
|
||||||
if (item.commandYear) {
|
if (item.commandYear) {
|
||||||
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
||||||
|
|
@ -5244,12 +5440,13 @@ export class CommandController extends Controller {
|
||||||
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
||||||
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||||
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||||
order:
|
// order:
|
||||||
profile.profileSalary.length >= 0
|
// profile.profileSalary.length >= 0
|
||||||
? profile.profileSalary.length > 0
|
// ? profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[0].order + 1
|
// ? profile.profileSalary[0].order + 1
|
||||||
: 1
|
// : 1
|
||||||
: null,
|
// : null,
|
||||||
|
order: nextOrder,
|
||||||
orgRoot: item.orgRoot,
|
orgRoot: item.orgRoot,
|
||||||
orgChild1: item.orgChild1,
|
orgChild1: item.orgChild1,
|
||||||
orgChild2: item.orgChild2,
|
orgChild2: item.orgChild2,
|
||||||
|
|
@ -5643,7 +5840,7 @@ 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({
|
||||||
relations: [
|
relations: [
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"posType",
|
"posType",
|
||||||
"posLevel",
|
"posLevel",
|
||||||
"current_holders",
|
"current_holders",
|
||||||
|
|
@ -5656,15 +5853,21 @@ export class CommandController extends Controller {
|
||||||
"current_holders.positions.posExecutive",
|
"current_holders.positions.posExecutive",
|
||||||
],
|
],
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
order: {
|
// order: {
|
||||||
profileSalary: {
|
// profileSalary: {
|
||||||
order: "DESC",
|
// order: "DESC",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
}
|
}
|
||||||
|
const lastSalary = await this.salaryRepo.findOne({
|
||||||
|
where: { profileId: item.profileId },
|
||||||
|
select: ["order"],
|
||||||
|
order: { order: "DESC" },
|
||||||
|
});
|
||||||
|
const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
|
||||||
let _commandYear = item.commandYear;
|
let _commandYear = item.commandYear;
|
||||||
if (item.commandYear) {
|
if (item.commandYear) {
|
||||||
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
||||||
|
|
@ -5740,12 +5943,13 @@ export class CommandController extends Controller {
|
||||||
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
||||||
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||||
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||||
order:
|
// order:
|
||||||
profile.profileSalary.length >= 0
|
// profile.profileSalary.length >= 0
|
||||||
? profile.profileSalary.length > 0
|
// ? profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[0].order + 1
|
// ? profile.profileSalary[0].order + 1
|
||||||
: 1
|
// : 1
|
||||||
: null,
|
// : null,
|
||||||
|
order: nextOrder,
|
||||||
orgRoot: orgRootRef?.orgRootName ?? null,
|
orgRoot: orgRootRef?.orgRootName ?? null,
|
||||||
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
|
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
|
||||||
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
|
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
|
||||||
|
|
@ -5804,6 +6008,42 @@ export class CommandController extends Controller {
|
||||||
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);
|
||||||
|
// Task #2190
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// item.commandDateAffect?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// profile.posLevel?.posLevelName ?? "",
|
||||||
|
// item.commandDateAffect ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// clearProfile.retireTypeName ?? "",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ import { CommandRecive } from "../entities/CommandRecive";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { CreatePosMasterHistoryOfficer, getTopDegrees } from "../services/PositionService";
|
import { CreatePosMasterHistoryOfficer, getTopDegrees } from "../services/PositionService";
|
||||||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||||
|
import { PostRetireToExprofile } from "./ExRetirementController";
|
||||||
@Route("api/v1/org/profile")
|
@Route("api/v1/org/profile")
|
||||||
@Tags("Profile")
|
@Tags("Profile")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -8194,7 +8194,7 @@ export class ProfileController extends Controller {
|
||||||
"current_holders.orgChild2",
|
"current_holders.orgChild2",
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"profileEducations",
|
"profileEducations",
|
||||||
"profileActpositions",
|
"profileActpositions",
|
||||||
],
|
],
|
||||||
|
|
@ -10858,6 +10858,41 @@ export class ProfileController extends Controller {
|
||||||
}
|
}
|
||||||
await removeProfileInOrganize(profile.id, "OFFICER");
|
await removeProfileInOrganize(profile.id, "OFFICER");
|
||||||
}
|
}
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// requestBody.dateLeave?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// profile.posLevel?.posLevelName ?? "",
|
||||||
|
// requestBody.dateLeave ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// "ถึงแก่กรรม",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ import { ProfileChildren } from "../entities/ProfileChildren";
|
||||||
import { ProfileDuty } from "../entities/ProfileDuty";
|
import { ProfileDuty } from "../entities/ProfileDuty";
|
||||||
import { getTopDegrees } from "../services/PositionService";
|
import { getTopDegrees } from "../services/PositionService";
|
||||||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||||
|
import { PostRetireToExprofile } from "./ExRetirementController";
|
||||||
@Route("api/v1/org/profile-employee")
|
@Route("api/v1/org/profile-employee")
|
||||||
@Tags("ProfileEmployee")
|
@Tags("ProfileEmployee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -5333,6 +5334,41 @@ export class ProfileEmployeeController extends Controller {
|
||||||
if (requestBody.isLeave == true) {
|
if (requestBody.isLeave == true) {
|
||||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||||
}
|
}
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// requestBody.dateLeave?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
||||||
|
// requestBody.dateLeave ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// "ถึงแก่กรรม",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5936,7 +5972,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
"current_holders.orgChild2",
|
"current_holders.orgChild2",
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
"profileSalary",
|
// "profileSalary",
|
||||||
"profileEducations",
|
"profileEducations",
|
||||||
],
|
],
|
||||||
order: {
|
order: {
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ import { deleteUser } from "../keycloak";
|
||||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||||
import { getTopDegrees } from "../services/PositionService";
|
import { getTopDegrees } from "../services/PositionService";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
|
import { PostRetireToExprofile } from "./ExRetirementController";
|
||||||
@Route("api/v1/org/profile-temp")
|
@Route("api/v1/org/profile-temp")
|
||||||
@Tags("ProfileEmployee")
|
@Tags("ProfileEmployee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -3547,6 +3548,41 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
if (requestBody.isLeave == true) {
|
if (requestBody.isLeave == true) {
|
||||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||||
}
|
}
|
||||||
|
let organizeName = "";
|
||||||
|
if (orgRootRef) {
|
||||||
|
const names = [
|
||||||
|
orgChild4Ref?.orgChild4Name,
|
||||||
|
orgChild3Ref?.orgChild3Name,
|
||||||
|
orgChild2Ref?.orgChild2Name,
|
||||||
|
orgChild1Ref?.orgChild1Name,
|
||||||
|
orgRootRef?.orgRootName,
|
||||||
|
].filter(Boolean);
|
||||||
|
organizeName = names.join(" ");
|
||||||
|
}
|
||||||
|
await PostRetireToExprofile(
|
||||||
|
// profile.citizenId ?? "",
|
||||||
|
// profile.prefix ?? "",
|
||||||
|
// profile.firstName ?? "",
|
||||||
|
// profile.lastName ?? "",
|
||||||
|
// requestBody.dateLeave?.getFullYear().toString() ?? "",
|
||||||
|
// profile.position,
|
||||||
|
// profile.posType?.posTypeName ?? "",
|
||||||
|
// `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
||||||
|
// requestBody.dateLeave ?? new Date(),
|
||||||
|
// organizeName,
|
||||||
|
// "ถึงแก่กรรม",
|
||||||
|
"310190004095X",
|
||||||
|
"จ.ส.อ.",
|
||||||
|
"dev",
|
||||||
|
"hrms",
|
||||||
|
"2026",
|
||||||
|
"เจ้าหน้าที่จัดเก็บรายได้",
|
||||||
|
"อื่นๆ",
|
||||||
|
"C 3",
|
||||||
|
new Date(2026, 0, 1),
|
||||||
|
"สำนักงานเขตบางกอกใหญ่",
|
||||||
|
"เกษียณ"
|
||||||
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,7 @@ export async function checkCommandType(commandId: string) {
|
||||||
].includes(String(_type?.commandType.code))
|
].includes(String(_type?.commandType.code))
|
||||||
) {
|
) {
|
||||||
// return false;
|
// return false;
|
||||||
return { status: false, LeaveType: null, leaveRemark: null };
|
return { status: false, LeaveType: null, leaveRemark: null, retireTypeName: null };
|
||||||
}
|
}
|
||||||
// return true;
|
// return true;
|
||||||
const _commandRecive = await commandReciveRepository.findOne({
|
const _commandRecive = await commandReciveRepository.findOne({
|
||||||
|
|
@ -461,47 +461,58 @@ export async function checkCommandType(commandId: string) {
|
||||||
});
|
});
|
||||||
|
|
||||||
let _leaveType: string = "";
|
let _leaveType: string = "";
|
||||||
|
let _retireTypeName: string = ""; //อิงตามเหตุผลการพ้นจากราชการ ข้อมูลทะเบียนประวัติผู้พ้นจากราชการ
|
||||||
switch (String(_type?.commandType.code)) {
|
switch (String(_type?.commandType.code)) {
|
||||||
case "C-PM-12": {
|
case "C-PM-12": {
|
||||||
_leaveType = "PROBATION_REPORT";
|
_leaveType = "PROBATION_REPORT";
|
||||||
|
_retireTypeName = "ผลการทดลองฯ ต่ำกว่ามาตรฐานที่กำหนด"
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-13": {
|
case "C-PM-13": {
|
||||||
_leaveType = "PLACEMENT_TRANSFER";
|
_leaveType = "PLACEMENT_TRANSFER";
|
||||||
|
_retireTypeName = "โอนออก";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-17": {
|
case "C-PM-17": {
|
||||||
_leaveType = "RETIRE_RESIGN";
|
_leaveType = "RETIRE_RESIGN";
|
||||||
|
_retireTypeName = "ลาออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-18": {
|
case "C-PM-18": {
|
||||||
_leaveType = "RETIRE_OUT";
|
_leaveType = "RETIRE_OUT";
|
||||||
|
_retireTypeName = "ให้ออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-19": {
|
case "C-PM-19": {
|
||||||
_leaveType = "DISCIPLINE_RESULT_REMOVE";
|
_leaveType = "DISCIPLINE_RESULT_REMOVE";
|
||||||
|
_retireTypeName = "ปลดออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-20": {
|
case "C-PM-20": {
|
||||||
_leaveType = "DISCIPLINE_RESULT_DISMISS";
|
_leaveType = "DISCIPLINE_RESULT_DISMISS";
|
||||||
|
_retireTypeName = "ไล่ออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-23": {
|
case "C-PM-23": {
|
||||||
_leaveType = "RETIRE_RESIGN_EMP";
|
_leaveType = "RETIRE_RESIGN_EMP";
|
||||||
|
_retireTypeName = "ลาออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "C-PM-43": {
|
case "C-PM-43": {
|
||||||
_leaveType = "RETIRE_OUT_EMP";
|
_leaveType = "RETIRE_OUT_EMP";
|
||||||
|
_retireTypeName = "ให้ออกจากราชการ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
_leaveType = "";
|
_leaveType = "";
|
||||||
|
_retireTypeName = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
status: true,
|
status: true,
|
||||||
LeaveType: _leaveType,
|
LeaveType: _leaveType,
|
||||||
leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null,
|
leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null,
|
||||||
|
retireTypeName: _retireTypeName ? _retireTypeName : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ export async function init() {
|
||||||
|
|
||||||
console.log("[AMQ] Listening for message...");
|
console.log("[AMQ] Listening for message...");
|
||||||
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
||||||
createConsumer(queue_org, channel, handler_org);
|
createConsumer(queue_org, channel, handler_org);
|
||||||
createConsumer(queue_org_draft, channel, handler_org_draft);
|
createConsumer(queue_org_draft, channel, handler_org_draft);
|
||||||
createConsumer(queue_command_noti, channel, handler_command_noti);
|
createConsumer(queue_command_noti, channel, handler_command_noti);
|
||||||
// createConsumer(queue2, channel, handler2);
|
// createConsumer(queue2, channel, handler2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue