Task #2208 กรณีขอแก้ไขข้อมูลทะเบียนประวัติ และ IDP และคนขออยู่ในสำนักปลัดกรุงเทพมหานคร
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s

This commit is contained in:
harid 2026-01-21 13:53:29 +07:00
parent 757da877f6
commit ae3a634595
3 changed files with 66 additions and 11 deletions

View file

@ -27,6 +27,7 @@ import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory
import { setLogDataDiff } from "../interfaces/utils";
import CallAPI from "../interfaces/call-api";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/profile/development-request")
@Tags("DevelopmentRequest")
@Security("bearerAuth")
@ -37,6 +38,7 @@ export class DevelopmentRequestController extends Controller {
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
@Get("user")
public async getDevelopmentRequestUser(
@ -298,12 +300,32 @@ export class DevelopmentRequestController extends Controller {
@Body() body: CreateDevelopmentRequest,
) {
const profile = await this.profileRepository.findOne({
where: { keycloak: req.user.sub },
relations: ["posLevel", "posType"],
relations: {
posLevel: true,
posType: true,
current_holders: true
},
where: {
keycloak: req.user.sub,
current_holders: {
orgRevision: {
orgRevisionIsCurrent: true,
orgRevisionIsDraft: false
}
}
}
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
isDeputy: true
},
where: {
id: profile.current_holders.find(x => x.orgRootId)!.orgRootId ?? ""
}
})
const before = null;
const data = new DevelopmentRequest();
@ -346,6 +368,7 @@ export class DevelopmentRequestController extends Controller {
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
})
.catch((error) => {
console.error("Error calling API:", error);

View file

@ -23,7 +23,7 @@ import { Brackets } from "typeorm";
import CallAPI from "../interfaces/call-api";
import permission from "../interfaces/permission";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/profile/edit")
@Tags("ProfileEdit")
@Security("bearerAuth")
@ -31,6 +31,7 @@ export class ProfileEditController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private profileEditRepo = AppDataSource.getRepository(ProfileEdit);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
@Get("user")
public async detailProfileEditUser(
@ -294,12 +295,32 @@ export class ProfileEditController extends Controller {
@Post()
public async newProfileEdit(@Request() req: RequestWithUser, @Body() body: CreateProfileEdit) {
const profile = await this.profileRepo.findOne({
where: { keycloak: req.user.sub },
relations: ["posLevel", "posType"],
relations: {
posLevel: true,
posType: true,
current_holders: true
},
where: {
keycloak: req.user.sub,
current_holders: {
orgRevision: {
orgRevisionIsCurrent: true,
orgRevisionIsDraft: false
}
}
}
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
isDeputy: true
},
where: {
id: profile.current_holders.find(x => x.orgRootId)!.orgRootId ?? ""
}
})
const data = new ProfileEdit();
const meta = {
@ -322,6 +343,7 @@ export class ProfileEditController extends Controller {
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
})
.catch((error) => {
console.error("Error calling API:", error);

View file

@ -145,12 +145,22 @@ export class WorkflowController extends Controller {
metaStates.find((metaState) => metaState.id === metaStateOp.metaStateId)?.order ===
state.order,
);
// Task #2207 กรณีคนขอโอนอยู่ในสำนักปลัดกรุงเทพมหานคร
if (body.isDeputy && metaStateOp.operator == "PersonnelOfficer" && correspondingState?.order == 1) {
return;
}
else if (body.isDeputy && metaStateOp.operator == "Officer" && [1, 2].includes(correspondingState?.order as number)) {
metaStateOp.operator = "PersonnelOfficer"
if (body.isDeputy) {
// Task #2207 กรณีคนขอโอนอยู่ในสำนักปลัดกรุงเทพมหานคร
if (body.sysName == "SYS_TRANSFER_REQ") {
if (metaStateOp.operator == "PersonnelOfficer" && correspondingState?.order == 1) {
return;
}
else if (metaStateOp.operator == "Officer" && [1, 2].includes(correspondingState?.order as number)) {
metaStateOp.operator = "PersonnelOfficer"
}
}
// Task #2208 กรณีขอแก้ไขข้อมูลทะเบียนประวัติ และ IDP และคนขออยู่ในสำนักปลัดกรุงเทพมหานคร
if (metaStateOp.operator == "Officer" &&
(["REGISTRY_PROFILE", "REGISTRY_PROFILE_EMP", "REGISTRY_IDP"].includes(body.sysName))
) {
metaStateOp.operator = "PersonnelOfficer"
}
}
if (correspondingState) {
const stateOperator = new StateOperator();