Merge branch 'develop' into adiDev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
This commit is contained in:
commit
95aad0b9fb
4 changed files with 72 additions and 3 deletions
|
|
@ -2411,9 +2411,9 @@ export class CommandController extends Controller {
|
|||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiYear(command.commandYear).toString()),
|
||||
commandExcecuteDate:
|
||||
command.commandExcecuteDate == null
|
||||
command.commandAffectDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)),
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
|
||||
operators:
|
||||
operators.length > 0
|
||||
? operators.map((x) => ({
|
||||
|
|
@ -2618,6 +2618,7 @@ export class CommandController extends Controller {
|
|||
const now = new Date();
|
||||
let command = new Command();
|
||||
let commandCode: string = "";
|
||||
let commandSysId: string = "";
|
||||
let _null: any = null;
|
||||
let userProfile: any = null;
|
||||
if (
|
||||
|
|
@ -2637,6 +2638,7 @@ export class CommandController extends Controller {
|
|||
if (!_command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบคำสั่งนี้ในระบบ");
|
||||
}
|
||||
commandSysId = _command.commandType.commandSysId;
|
||||
commandCode = _command.commandType.code;
|
||||
command = _command;
|
||||
} else {
|
||||
|
|
@ -2651,6 +2653,7 @@ export class CommandController extends Controller {
|
|||
if (!commandType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
}
|
||||
commandSysId = commandType.commandSysId;
|
||||
commandCode = commandType.code;
|
||||
command.detailHeader = commandType.detailHeader;
|
||||
command.detailBody = commandType.detailBody;
|
||||
|
|
@ -2795,7 +2798,7 @@ export class CommandController extends Controller {
|
|||
|
||||
const path = commandTypePath(commandCode);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
if (!["C-PM-26", "C-PM-25"].includes(commandCode)) {
|
||||
if (commandSysId && commandSysId.toLocaleUpperCase().trim() !== "DISCIPLINE") {
|
||||
await new CallAPI()
|
||||
.PostData(request, path, {
|
||||
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
} from "../entities/ProfileChangeName";
|
||||
import { updateName } from "../keycloak";
|
||||
import permission from "../interfaces/permission";
|
||||
import { updateHolderProfileHistory } from "../services/PositionService";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/changeName")
|
||||
@Tags("ProfileChangeName")
|
||||
|
|
@ -127,6 +128,9 @@ export class ProfileChangeNameController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
// บันทึกประวัติคนครองตำแหน่ง (ถ้า profile นี้ครองตำแหน่งอยู่)
|
||||
await updateHolderProfileHistory(profile.id, req);
|
||||
|
||||
return new HttpSuccess(data.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import {
|
|||
} from "../entities/ProfileChangeName";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { updateHolderProfileHistory } from "../services/PositionService";
|
||||
import { updateName } from "../keycloak";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/changeName")
|
||||
|
|
@ -133,6 +134,9 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
// บันทึกประวัติคนครองตำแหน่ง (ถ้า profile นี้ครองตำแหน่งอยู่)
|
||||
await updateHolderProfileHistory(profile.id, req, "EMPLOYEE");
|
||||
|
||||
return new HttpSuccess(data.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -501,3 +501,61 @@ export async function BatchSavePosMasterHistoryOfficer(
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* อัพเดทประวัติคนครองตำแหน่งเมื่อมีการเปลี่ยนแปลงข้อมูล profile
|
||||
* เช่น เปลี่ยนชื่อ - นามสกุล
|
||||
* ใช้สำหรับบันทึกประวัติเมื่อ profile ที่ครองตำแหน่งมีการเปลี่ยนแปลง
|
||||
*
|
||||
* @param profileId ID ของ profile ที่ต้องการตรวจสอบ
|
||||
* @param request RequestWithUser สำหรับบันทึกข้อมูลผู้ดำเนินการ
|
||||
* @param type "OFFICER" สำหรับข้าราชการ | "EMPLOYEE" สำหรับลูกจ้างประจำ (default: "OFFICER")
|
||||
*/
|
||||
export async function updateHolderProfileHistory(
|
||||
profileId: string,
|
||||
request: RequestWithUser,
|
||||
type: "OFFICER" | "EMPLOYEE" = "OFFICER",
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (type === "OFFICER") {
|
||||
const posMasterRepo = AppDataSource.getRepository(PosMaster);
|
||||
const posMaster = await posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holderId: profileId,
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
}
|
||||
},
|
||||
relations: {
|
||||
orgRevision : true
|
||||
}
|
||||
});
|
||||
|
||||
if (posMaster) {
|
||||
await CreatePosMasterHistoryOfficer(posMaster.id, request);
|
||||
}
|
||||
} else if (type === "EMPLOYEE") {
|
||||
const empPosMasterRepo = AppDataSource.getRepository(EmployeePosMaster);
|
||||
const employeePosMaster = await empPosMasterRepo.findOne({
|
||||
where: {
|
||||
current_holderId: profileId,
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
}
|
||||
},
|
||||
relations: {
|
||||
orgRevision : true
|
||||
}
|
||||
});
|
||||
|
||||
if (employeePosMaster) {
|
||||
await CreatePosMasterHistoryEmployee(employeePosMaster.id, request);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("updateHolderProfileHistory error:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue