diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 59377d32..e9d035bf 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -700,8 +700,8 @@ export class EmployeePositionController extends Controller { // posMaster.isStaff = requestBody.isStaff == null?_null:requestBody.isStaff; // posMaster.positionSign = requestBody.positionSign == null ? _null : requestBody.positionSign; // posMaster.isOfficer = requestBody.isOfficer; - posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; - posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; + posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix ?? _null; + posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix ?? _null; posMaster.reason = requestBody.reason == null ? "" : requestBody.reason; posMaster.orgRootId = null; posMaster.orgChild1Id = null; @@ -1233,6 +1233,7 @@ export class EmployeePositionController extends Controller { return { id: posMaster.id, + current_holderId: posMaster.current_holderId, orgRootId: posMaster.orgRootId, orgChild1Id: posMaster.orgChild1Id, orgChild2Id: posMaster.orgChild2Id, diff --git a/src/controllers/EmployeeTempPositionController.ts b/src/controllers/EmployeeTempPositionController.ts index b2e2da56..56bf5ea2 100644 --- a/src/controllers/EmployeeTempPositionController.ts +++ b/src/controllers/EmployeeTempPositionController.ts @@ -997,6 +997,7 @@ export class EmployeeTempPositionController extends Controller { return { id: posMaster.id, + current_holderId: posMaster.current_holderId, orgRootId: posMaster.orgRootId, orgChild1Id: posMaster.orgChild1Id, orgChild2Id: posMaster.orgChild2Id, diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 0131d3b2..d608bbbc 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1250,8 +1250,8 @@ export class PositionController extends Controller { ? _null : requestBody.positionSign; posMaster.posMasterNo = requestBody.posMasterNo; - posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; - posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; + posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix ?? _null; + posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix ?? _null; posMaster.reason = requestBody.reason == null ? "" : requestBody.reason; let orgRoot: any = null; @@ -1913,6 +1913,7 @@ export class PositionController extends Controller { return { id: posMaster.id, + current_holderId: posMaster.current_holderId, isDirector: posMaster.isDirector, orgRootId: posMaster.orgRootId, orgChild1Id: posMaster.orgChild1Id, @@ -2342,6 +2343,7 @@ export class PositionController extends Controller { return { id: posMaster.id, + current_holderId: posMaster.current_holderId, isDirector: posMaster.isDirector, orgRootId: posMaster.orgRootId, orgChild1Id: posMaster.orgChild1Id, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index ccb5617d..1e909cc5 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -269,17 +269,18 @@ export class ProfileController extends Controller { : null, position: Extension.ToThaiNumber( Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? (item.positionCee??"") : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee ?? "" : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, ), ), posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", - orgRoot: item.orgRoot != null ? Extension.ToThaiNumber( item.orgRoot) : "", - orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber( item.orgChild1) : "", - orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber( item.orgChild2) : "", - orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber( item.orgChild3) : "", - orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber( item.orgChild4) : "", - positionCee: item.positionCee != null ? Extension.ToThaiNumber( item.positionCee) : "", - positionExecutive: item.positionExecutive != null ? Extension.ToThaiNumber( item.positionExecutive) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber(item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber(item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber(item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber(item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber(item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber(item.positionCee) : "", + positionExecutive: + item.positionExecutive != null ? Extension.ToThaiNumber(item.positionExecutive) : "", })) : [ { @@ -356,7 +357,7 @@ export class ProfileController extends Controller { salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? (salary_raw[0].positionCee??"") : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee ?? "" : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, ), ) : "", @@ -7434,6 +7435,12 @@ export class ProfileController extends Controller { null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4; + const position = await this.positionRepository.findOne({ + relations: ["posExecutive"], + where: { + posMasterId: posMaster?.id, + }, + }); const _profile: any = { profileId: profile.id, prefix: profile.prefix, @@ -7451,6 +7458,10 @@ export class ProfileController extends Controller { posTypeName: profile.posType == null ? null : profile.posType.posTypeName, posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank, posTypeId: profile.posType == null ? null : profile.posType.id, + posExecutiveName: + position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutiveName, orgRevisionId: root == null ? null : root.orgRevisionId, rootId: root == null ? null : root.id, rootDnaId: root == null ? null : root.ancestorDNA, diff --git a/src/entities/EmployeePosMaster.ts b/src/entities/EmployeePosMaster.ts index ed79835f..c1f0e143 100644 --- a/src/entities/EmployeePosMaster.ts +++ b/src/entities/EmployeePosMaster.ts @@ -235,13 +235,13 @@ export class EmployeePosMaster extends EntityBase { export class CreateEmployeePosMaster { @Column() - posMasterNoPrefix: string; + posMasterNoPrefix: string | null; @Column() posMasterNo: number; @Column() - posMasterNoSuffix: string; + posMasterNoSuffix: string | null; @Column("uuid") positions: CreateEmployeePosDict[]; diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index 938067e9..59018baa 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -267,13 +267,13 @@ export class PosMaster extends EntityBase { export class CreatePosMaster { @Column() - posMasterNoPrefix: string; + posMasterNoPrefix: string | null; @Column() posMasterNo: number; @Column() - posMasterNoSuffix: string; + posMasterNoSuffix: string | null; @Column("uuid") positions: CreatePosDict[]; diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 6cea1467..c4f81764 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -1274,13 +1274,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - item.posMasterAssigns = item.posMasterAssigns.map( + posMaster.posMasterAssigns = item.posMasterAssigns.map( ({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, }), ); - posMaster.posMasterAssigns = item.posMasterAssigns; + await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1365,13 +1365,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { await posMasterRepository.save(posMaster); // Copy assignments - item.posMasterAssigns = item.posMasterAssigns.map( + posMaster.posMasterAssigns = item.posMasterAssigns.map( ({ id, ...rest }: PosMasterAssign) => ({ ...rest, posMasterId: posMaster.id, }), ); - posMaster.posMasterAssigns = item.posMasterAssigns; + await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1464,6 +1464,7 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { posMasterId: posMaster.id, }), ); + await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1558,6 +1559,7 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { posMasterId: posMaster.id, }), ); + await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) { @@ -1655,6 +1657,7 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { posMasterId: posMaster.id, }), ); + await posMasterRepository.save(posMaster); // Create positions for await (const pos of item.positions) {