From e0be0fbb82467491ed3b6e360a3aa5ba54c5c0ad Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 17 Feb 2025 22:34:41 +0700 Subject: [PATCH 1/8] no message --- src/controllers/ImportDataController.ts | 10 +++++++++- src/entities/HR_EDUCATION_EMP.ts | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index acb0007d..4f7f6626 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -977,7 +977,14 @@ export class ImportDataController extends Controller { profiles.map(async (_item) => { const existingProfile = await this.HR_EDUCATION_EMPRepo.find({ where: { CIT: _item.citizenId }, - select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"], + select: [ + "CIT", + "EDUCATION_CODE", + "START_EDUCATION_YEAR", + "EDUCATION_YEAR", + "INSTITUE", + "EDUCATION_SEQ", + ], }); const educationLevel = await this.profileEducationRepo.findOne({ @@ -1009,6 +1016,7 @@ export class ImportDataController extends Controller { education.profileEmployeeId = _item.id; education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; education.institute = item.INSTITUE; + education.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ); education.startDate = startDate; education.endDate = endDate; education.createdUserId = request.user.sub; diff --git a/src/entities/HR_EDUCATION_EMP.ts b/src/entities/HR_EDUCATION_EMP.ts index add09acb..bec7fed0 100644 --- a/src/entities/HR_EDUCATION_EMP.ts +++ b/src/entities/HR_EDUCATION_EMP.ts @@ -45,4 +45,11 @@ export class HR_EDUCATION_EMP { default: null, }) INSTITUE: string; + + @Column({ + nullable: true, + length: 255, + default: null, + }) + EDUCATION_SEQ: string; } From e1e400a24a3a47271506f1de4f9d6f51447531ee Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 09:38:11 +0700 Subject: [PATCH 2/8] =?UTF-8?q?=E0=B8=A1=E0=B8=AD=E0=B8=9A=E0=B8=AB?= =?UTF-8?q?=E0=B8=A1=E0=B8=B2=E0=B8=A2=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=A7=E0=B9=88=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 767d0a55..46da2c2a 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -6404,7 +6404,7 @@ export class OrganizationController extends Controller { .filter( (x) => x.orgChild1Id == null && - x.current_holderId != null && + // x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true, ) @@ -6451,7 +6451,7 @@ export class OrganizationController extends Controller { .filter( (x) => x.orgChild2Id == null && - x.current_holderId != null && + // x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true, ) @@ -6506,7 +6506,7 @@ export class OrganizationController extends Controller { .filter( (x) => x.orgChild3Id == null && - x.current_holderId != null && + // x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true, ) @@ -6568,7 +6568,7 @@ export class OrganizationController extends Controller { .filter( (x) => x.orgChild4Id == null && - x.current_holderId != null && + // x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true, ) @@ -6636,9 +6636,8 @@ export class OrganizationController extends Controller { orgChild4.posMasters .filter( (x) => - x.current_holderId != null && - x.posMasterOrder <= 3 && - x.isDirector === true, + // x.current_holderId != null && + x.posMasterOrder <= 3 && x.isDirector === true, ) .map(async (x) => ({ posmasterId: x.id, From 3a35b91a590a6946d5f9613d30e700ae1d371667 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 18 Feb 2025 10:22:33 +0700 Subject: [PATCH 3/8] migrate + update view --- src/entities/view/viewDirector.ts | 146 ++++++++---------- .../1739848553779-updateViewDirector.ts | 84 ++++++++++ 2 files changed, 148 insertions(+), 82 deletions(-) create mode 100644 src/migration/1739848553779-updateViewDirector.ts diff --git a/src/entities/view/viewDirector.ts b/src/entities/view/viewDirector.ts index 8ed6b058..a9eceb45 100644 --- a/src/entities/view/viewDirector.ts +++ b/src/entities/view/viewDirector.ts @@ -2,92 +2,74 @@ import { ViewColumn, ViewEntity } from "typeorm"; @ViewEntity({ expression: `SELECT - \`profile\`.\`id\` AS \`Id\`, - \`profile\`.\`prefix\` AS \`prefix\`, - \`profile\`.\`firstName\` AS \`firstName\`, - \`profile\`.\`lastName\` AS \`lastName\`, - \`profile\`.\`citizenId\` AS \`citizenId\`, - \`profile\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRoot\`.\`orgRootShortName\` - WHEN (\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1\`.\`orgChild1ShortName\` - WHEN (\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2\`.\`orgChild2ShortName\` - WHEN (\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3\`.\`orgChild3ShortName\` - ELSE \`orgChild4\`.\`orgChild4ShortName\` - END), - \`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`posType\`.\`posTypeName\` AS \`posType\`, - \`posExecutive\`.\`posExecutiveName\` AS \`posExecutiveName\`, - \`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`orgChild1\`.\`isOfficer\` AS \`isOfficer\`, - \`posMaster\`.\`orgRevisionId\` AS \`orgRevisionId\`, - \`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`posMaster\`.\`id\`, \`profile\`.\`id\`) AS \`key\`, + profile.id AS Id, + profile.prefix AS prefix, + profile.firstName AS firstName, + profile.lastName AS lastName, + profile.citizenId AS citizenId, + profile.position AS position, + CONCAT( + CASE + WHEN posMaster.orgChild1Id IS NULL THEN orgRoot.orgRootShortName + WHEN posMaster.orgChild2Id IS NULL THEN orgChild1.orgChild1ShortName + WHEN posMaster.orgChild3Id IS NULL THEN orgChild2.orgChild2ShortName + WHEN posMaster.orgChild4Id IS NULL THEN orgChild3.orgChild3ShortName + ELSE orgChild4.orgChild4ShortName + END, + posMaster.posMasterNo + ) AS posNo, + posMaster.isDirector AS isDirector, + posLevel.posLevelName AS posLevel, + posType.posTypeName AS posType, + posExecutive.posExecutiveName AS posExecutiveName, + orgRoot.isDeputy AS isDeputy, + orgChild1.isOfficer AS isOfficer, + posMaster.orgRevisionId AS orgRevisionId, + posMaster.orgRootId AS orgRootId, + posMaster.orgChild1Id AS orgChild1Id, + posMaster.orgChild2Id AS orgChild2Id, + posMaster.orgChild3Id AS orgChild3Id, + posMaster.orgChild4Id AS orgChild4Id, + CONCAT(posMaster.id, profile.id) AS \`key\`, ( - SELECT \`actFullNameId\` - FROM \`view_director_acting\` AS \`acting\` - WHERE \`acting\`.\`Id\` = \`posMaster\`.\`current_holderId\` - AND \`acting\`.\`orgRootId\` = \`posMaster\`.\`orgRootId\` - AND ( - (\`acting\`.\`orgChild1Id\` IS NULL AND \`posMaster\`.\`orgChild1Id\` IS NULL) - OR (\`acting\`.\`orgChild1Id\` = \`posMaster\`.\`orgChild1Id\`) - ) - AND ( - (\`acting\`.\`orgChild2Id\` IS NULL AND \`posMaster\`.\`orgChild2Id\` IS NULL) - OR (\`acting\`.\`orgChild2Id\` = \`posMaster\`.\`orgChild2Id\`) - ) - AND ( - (\`acting\`.\`orgChild3Id\` IS NULL AND \`posMaster\`.\`orgChild3Id\` IS NULL) - OR (\`acting\`.\`orgChild3Id\` = \`posMaster\`.\`orgChild3Id\`) - ) - AND ( - (\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL) - OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`) - ) LIMIT 1 - ) AS \`actFullNameId\`, + SELECT actFullNameId + FROM view_director_acting AS acting + WHERE acting.Id = posMaster.current_holderId + AND acting.orgRootId = posMaster.orgRootId + AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL) + AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL) + AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL) + AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL) + LIMIT 1 + ) AS actFullNameId, ( - SELECT \`actFullName\` - FROM \`view_director_acting\` AS \`acting\` - WHERE \`acting\`.\`Id\` = \`posMaster\`.\`current_holderId\` - AND \`acting\`.\`orgRootId\` = \`posMaster\`.\`orgRootId\` - AND ( - (\`acting\`.\`orgChild1Id\` IS NULL AND \`posMaster\`.\`orgChild1Id\` IS NULL) - OR (\`acting\`.\`orgChild1Id\` = \`posMaster\`.\`orgChild1Id\`) - ) - AND ( - (\`acting\`.\`orgChild2Id\` IS NULL AND \`posMaster\`.\`orgChild2Id\` IS NULL) - OR (\`acting\`.\`orgChild2Id\` = \`posMaster\`.\`orgChild2Id\`) - ) - AND ( - (\`acting\`.\`orgChild3Id\` IS NULL AND \`posMaster\`.\`orgChild3Id\` IS NULL) - OR (\`acting\`.\`orgChild3Id\` = \`posMaster\`.\`orgChild3Id\`) - ) - AND ( - (\`acting\`.\`orgChild4Id\` IS NULL AND \`posMaster\`.\`orgChild4Id\` IS NULL) - OR (\`acting\`.\`orgChild4Id\` = \`posMaster\`.\`orgChild4Id\`) - ) LIMIT 1 - ) AS \`actFullName\` - + SELECT actFullName + FROM view_director_acting AS acting + WHERE acting.Id = posMaster.current_holderId + AND acting.orgRootId = posMaster.orgRootId + AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL) + AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL) + AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL) + AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL) + LIMIT 1 + ) AS actFullName FROM - ((((((((((\`posMaster\` - JOIN \`profile\` ON ((\`posMaster\`.\`current_holderId\` = \`profile\`.\`id\`))) - LEFT JOIN \`orgRoot\` ON ((\`posMaster\`.\`orgRootId\` = \`orgRoot\`.\`id\`))) - LEFT JOIN \`orgChild1\` ON ((\`posMaster\`.\`orgChild1Id\` = \`orgChild1\`.\`id\`))) - LEFT JOIN \`orgChild2\` ON ((\`posMaster\`.\`orgChild2Id\` = \`orgChild2\`.\`id\`))) - LEFT JOIN \`orgChild3\` ON ((\`posMaster\`.\`orgChild3Id\` = \`orgChild3\`.\`id\`))) - LEFT JOIN \`orgChild4\` ON ((\`posMaster\`.\`orgChild4Id\` = \`orgChild4\`.\`id\`))) - JOIN \`posLevel\` ON ((\`profile\`.\`posLevelId\` = \`posLevel\`.\`id\`))) - JOIN \`posType\` ON ((\`profile\`.\`posTypeId\` = \`posType\`.\`id\`))) - LEFT JOIN \`position\` ON ((\`posMaster\`.\`id\` = \`position\`.\`posMasterId\`))) - LEFT JOIN \`posExecutive\` ON ((\`position\`.\`posExecutiveId\` = \`posExecutive\`.\`id\`))) + posMaster + JOIN profile ON posMaster.current_holderId = profile.id + LEFT JOIN orgRoot ON posMaster.orgRootId = orgRoot.id + LEFT JOIN orgChild1 ON posMaster.orgChild1Id = orgChild1.id + LEFT JOIN orgChild2 ON posMaster.orgChild2Id = orgChild2.id + LEFT JOIN orgChild3 ON posMaster.orgChild3Id = orgChild3.id + LEFT JOIN orgChild4 ON posMaster.orgChild4Id = orgChild4.id + JOIN posLevel ON profile.posLevelId = posLevel.id + JOIN posType ON profile.posTypeId = posType.id + LEFT JOIN position ON posMaster.id = position.posMasterId + LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id + INNER JOIN orgRevision ON posMaster.orgRevisionId = orgRevision.id WHERE - (\`position\`.\`positionIsSelected\` = TRUE)`, + (position.positionIsSelected = TRUE) + AND (orgRevision.orgRevisionIsCurrent = TRUE + AND orgRevision.orgRevisionIsDraft = FALSE)` }) export class viewDirector { @ViewColumn() diff --git a/src/migration/1739848553779-updateViewDirector.ts b/src/migration/1739848553779-updateViewDirector.ts new file mode 100644 index 00000000..f2ba75de --- /dev/null +++ b/src/migration/1739848553779-updateViewDirector.ts @@ -0,0 +1,84 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateViewDirector1739848553779 implements MigrationInterface { + name = 'UpdateViewDirector1739848553779' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT + profile.id AS Id, + profile.prefix AS prefix, + profile.firstName AS firstName, + profile.lastName AS lastName, + profile.citizenId AS citizenId, + profile.position AS position, + CONCAT( + CASE + WHEN posMaster.orgChild1Id IS NULL THEN orgRoot.orgRootShortName + WHEN posMaster.orgChild2Id IS NULL THEN orgChild1.orgChild1ShortName + WHEN posMaster.orgChild3Id IS NULL THEN orgChild2.orgChild2ShortName + WHEN posMaster.orgChild4Id IS NULL THEN orgChild3.orgChild3ShortName + ELSE orgChild4.orgChild4ShortName + END, + posMaster.posMasterNo + ) AS posNo, + posMaster.isDirector AS isDirector, + posLevel.posLevelName AS posLevel, + posType.posTypeName AS posType, + posExecutive.posExecutiveName AS posExecutiveName, + orgRoot.isDeputy AS isDeputy, + orgChild1.isOfficer AS isOfficer, + posMaster.orgRevisionId AS orgRevisionId, + posMaster.orgRootId AS orgRootId, + posMaster.orgChild1Id AS orgChild1Id, + posMaster.orgChild2Id AS orgChild2Id, + posMaster.orgChild3Id AS orgChild3Id, + posMaster.orgChild4Id AS orgChild4Id, + CONCAT(posMaster.id, profile.id) AS \`key\`, + ( + SELECT actFullNameId + FROM view_director_acting AS acting + WHERE acting.Id = posMaster.current_holderId + AND acting.orgRootId = posMaster.orgRootId + AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL) + AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL) + AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL) + AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL) + LIMIT 1 + ) AS actFullNameId, + ( + SELECT actFullName + FROM view_director_acting AS acting + WHERE acting.Id = posMaster.current_holderId + AND acting.orgRootId = posMaster.orgRootId + AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL) + AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL) + AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL) + AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL) + LIMIT 1 + ) AS actFullName + FROM + posMaster + JOIN profile ON posMaster.current_holderId = profile.id + LEFT JOIN orgRoot ON posMaster.orgRootId = orgRoot.id + LEFT JOIN orgChild1 ON posMaster.orgChild1Id = orgChild1.id + LEFT JOIN orgChild2 ON posMaster.orgChild2Id = orgChild2.id + LEFT JOIN orgChild3 ON posMaster.orgChild3Id = orgChild3.id + LEFT JOIN orgChild4 ON posMaster.orgChild4Id = orgChild4.id + JOIN posLevel ON profile.posLevelId = posLevel.id + JOIN posType ON profile.posTypeId = posType.id + LEFT JOIN position ON posMaster.id = position.posMasterId + LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id + INNER JOIN orgRevision ON posMaster.orgRevisionId = orgRevision.id + WHERE + (position.positionIsSelected = TRUE) + AND (orgRevision.orgRevisionIsCurrent = TRUE + AND orgRevision.orgRevisionIsDraft = FALSE)`); + await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n profile.id AS Id,\n profile.prefix AS prefix,\n profile.firstName AS firstName,\n profile.lastName AS lastName,\n profile.citizenId AS citizenId,\n profile.position AS position,\n CONCAT(\n CASE \n WHEN posMaster.orgChild1Id IS NULL THEN orgRoot.orgRootShortName\n WHEN posMaster.orgChild2Id IS NULL THEN orgChild1.orgChild1ShortName\n WHEN posMaster.orgChild3Id IS NULL THEN orgChild2.orgChild2ShortName\n WHEN posMaster.orgChild4Id IS NULL THEN orgChild3.orgChild3ShortName\n ELSE orgChild4.orgChild4ShortName\n END,\n posMaster.posMasterNo\n ) AS posNo,\n posMaster.isDirector AS isDirector,\n posLevel.posLevelName AS posLevel,\n posType.posTypeName AS posType,\n posExecutive.posExecutiveName AS posExecutiveName,\n orgRoot.isDeputy AS isDeputy,\n orgChild1.isOfficer AS isOfficer,\n posMaster.orgRevisionId AS orgRevisionId,\n posMaster.orgRootId AS orgRootId,\n posMaster.orgChild1Id AS orgChild1Id,\n posMaster.orgChild2Id AS orgChild2Id,\n posMaster.orgChild3Id AS orgChild3Id,\n posMaster.orgChild4Id AS orgChild4Id,\n CONCAT(posMaster.id, profile.id) AS `key`,\n (\n SELECT actFullNameId \n FROM view_director_acting AS acting\n WHERE acting.Id = posMaster.current_holderId \n AND acting.orgRootId = posMaster.orgRootId \n AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL)\n AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL)\n AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL)\n AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL)\n LIMIT 1\n ) AS actFullNameId,\n (\n SELECT actFullName \n FROM view_director_acting AS acting\n WHERE acting.Id = posMaster.current_holderId \n AND acting.orgRootId = posMaster.orgRootId \n AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL)\n AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL)\n AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL)\n AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL)\n LIMIT 1\n ) AS actFullName\n FROM\n posMaster\n JOIN profile ON posMaster.current_holderId = profile.id\n LEFT JOIN orgRoot ON posMaster.orgRootId = orgRoot.id\n LEFT JOIN orgChild1 ON posMaster.orgChild1Id = orgChild1.id\n LEFT JOIN orgChild2 ON posMaster.orgChild2Id = orgChild2.id\n LEFT JOIN orgChild3 ON posMaster.orgChild3Id = orgChild3.id\n LEFT JOIN orgChild4 ON posMaster.orgChild4Id = orgChild4.id\n JOIN posLevel ON profile.posLevelId = posLevel.id\n JOIN posType ON profile.posTypeId = posType.id\n LEFT JOIN position ON posMaster.id = position.posMasterId\n LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id\n INNER JOIN orgRevision ON posMaster.orgRevisionId = orgRevision.id\n WHERE\n (position.positionIsSelected = TRUE)\n AND (orgRevision.orgRevisionIsCurrent = TRUE\n AND orgRevision.orgRevisionIsDraft = FALSE)"]); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); + await queryRunner.query(`DROP VIEW \`view_director\``); + } + +} From 54c847cdd698f1a3b44c1ad61294a47f594f5551 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 10:34:31 +0700 Subject: [PATCH 4/8] find isCommission --- src/controllers/OrganizationController.ts | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 46da2c2a..8e170bfd 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8024,4 +8024,50 @@ export class OrganizationController extends Controller { } return data; } + /** + * API หา สกก1 + * + * @summary - หา สกก1 (ADMIN) + * + */ + @Get("find/head/officer") + async findIsHeadOfficer(@Request() request: RequestWithUser) { + const posMaster = await this.posMasterRepository.find({ + where: { + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + orgRoot: { isCommission: true }, + }, + order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } }, + relations: [ + "current_holder", + "posMasterActChilds", + "posMasterActChilds.posMasterChild", + "posMasterActChilds.posMasterChild.current_holder", + ], + }); + if (posMaster.length <= 0) { + return new HttpSuccess({ name: "", position: "" }); + } + if (posMaster[0].current_holder == null) { + if ( + posMaster[0].posMasterActChilds.length <= 0 || + posMaster[0].posMasterActChilds[0].posMasterChild == null || + posMaster[0].posMasterActChilds[0].posMasterChild.current_holder == null + ) { + return new HttpSuccess({ + name: "", + position: "", + }); + } + return new HttpSuccess({ + name: `${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.prefix}${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.firstName} ${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.lastName}`, + position: posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.position, + }); + } else { + return new HttpSuccess({ + name: `${posMaster[0].current_holder.prefix}${posMaster[0].current_holder.firstName} ${posMaster[0].current_holder.lastName}`, + position: posMaster[0].current_holder.position, + }); + } + } } From 3fb433dbe3684dc88bcf34973900a8d89b54326e Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 10:49:58 +0700 Subject: [PATCH 5/8] no message --- src/controllers/OrganizationController.ts | 9 ++++++--- src/entities/ProfileEducation.ts | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 8e170bfd..c486c017 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8046,7 +8046,10 @@ export class OrganizationController extends Controller { ], }); if (posMaster.length <= 0) { - return new HttpSuccess({ name: "", position: "" }); + return new HttpSuccess({ + name: ".............................", + position: ".............................", + }); } if (posMaster[0].current_holder == null) { if ( @@ -8055,8 +8058,8 @@ export class OrganizationController extends Controller { posMaster[0].posMasterActChilds[0].posMasterChild.current_holder == null ) { return new HttpSuccess({ - name: "", - position: "", + name: ".............................", + position: ".............................", }); } return new HttpSuccess({ diff --git a/src/entities/ProfileEducation.ts b/src/entities/ProfileEducation.ts index 62733214..be379d85 100644 --- a/src/entities/ProfileEducation.ts +++ b/src/entities/ProfileEducation.ts @@ -178,8 +178,7 @@ export class ProfileEducation extends EntityBase { @Column({ nullable: true, - comment: - "ลำดับชั้นของเครื่องราช เอาไว้ตรวจสอบเวลาขอว่าต้องได้ชั้นที่สูงกว่าที่เคยได้รับแล้วเท่านั้น", + comment: "ลำดับ", default: null, }) level: number; From 593406f609bedf4fd820880bfd5e2db67357fd68 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 12:12:59 +0700 Subject: [PATCH 6/8] no message --- src/controllers/OrganizationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index c486c017..4c2c86b0 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8036,6 +8036,7 @@ export class OrganizationController extends Controller { where: { orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, orgRoot: { isCommission: true }, + isDirector: true, }, order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } }, relations: [ From 28bfc04d6450b32249accc618e2a9bd96ea87cea Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 13:19:33 +0700 Subject: [PATCH 7/8] no message --- src/controllers/OrganizationController.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 4c2c86b0..c5615c4c 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8048,8 +8048,8 @@ export class OrganizationController extends Controller { }); if (posMaster.length <= 0) { return new HttpSuccess({ - name: ".............................", - position: ".............................", + name: "......................................................", + position: "......................................................", }); } if (posMaster[0].current_holder == null) { @@ -8059,8 +8059,8 @@ export class OrganizationController extends Controller { posMaster[0].posMasterActChilds[0].posMasterChild.current_holder == null ) { return new HttpSuccess({ - name: ".............................", - position: ".............................", + name: "......................................................", + position: "......................................................", }); } return new HttpSuccess({ From 539f433bd7b91fa0deb3edb08d0e6109889ee06c Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 18 Feb 2025 23:02:38 +0700 Subject: [PATCH 8/8] no message --- .../OrganizationDotnetController.ts | 40 +-- src/controllers/ProfileController.ts | 4 +- src/controllers/ProfileEmployeeController.ts | 263 +++++++++++++++--- .../ProfileEmployeeTempController.ts | 1 + 4 files changed, 242 insertions(+), 66 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index c9c49c45..afde8364 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -1213,31 +1213,31 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgRoot.ancestorDNA ?? null, + )?.orgRoot?.ancestorDNA ?? null, child1DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild3.ancestorDNA ?? null, + )?.orgChild3?.ancestorDNA ?? null, child2DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild2.ancestorDNA ?? null, + )?.orgChild2?.ancestorDNA ?? null, child3DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild3.ancestorDNA ?? null, + )?.orgChild3?.ancestorDNA ?? null, child4DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild4.ancestorDNA ?? null, + )?.orgChild4?.ancestorDNA ?? null, commander: fullname, posLevel: profile.posLevel?.posLevelName ?? null, posType: profile.posType?.posTypeName ?? null, @@ -1510,31 +1510,31 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgRoot.ancestorDNA ?? null, + )?.orgRoot?.ancestorDNA ?? null, child1DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild1.ancestorDNA ?? null, + )?.orgChild1?.ancestorDNA ?? null, child2DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild2.ancestorDNA ?? null, + )?.orgChild2?.ancestorDNA ?? null, child3DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild3.ancestorDNA ?? null, + )?.orgChild3?.ancestorDNA ?? null, child4DnaId: profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild4.ancestorDNA ?? null, + )?.orgChild4?.ancestorDNA ?? null, commander: fullname, posLevel: profile.posLevel?.posLevelName ?? null, posType: profile.posType?.posTypeName ?? null, @@ -2276,7 +2276,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgRoot.ancestorDNA ?? null, + )?.orgRoot?.ancestorDNA ?? null, child1: profile?.current_holders?.find( (x) => @@ -2294,7 +2294,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild1.ancestorDNA ?? null, + )?.orgChild1?.ancestorDNA ?? null, child2: profile?.current_holders?.find( (x) => @@ -2312,7 +2312,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild2.ancestorDNA ?? null, + )?.orgChild2?.ancestorDNA ?? null, child3: profile?.current_holders?.find( (x) => @@ -2330,7 +2330,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild3.ancestorDNA ?? null, + )?.orgChild3?.ancestorDNA ?? null, child4: profile?.current_holders?.find( (x) => @@ -2348,7 +2348,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild4.ancestorDNA ?? null, + )?.orgChild4?.ancestorDNA ?? null, posNo: shortName ?? "", }; }); @@ -2643,7 +2643,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgRoot.ancestorDNA ?? null, + )?.orgRoot?.ancestorDNA ?? null, child1: profile?.current_holders?.find( (x) => @@ -2661,7 +2661,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild1.ancestorDNA ?? null, + )?.orgChild1?.ancestorDNA ?? null, child2: profile?.current_holders?.find( (x) => @@ -2679,7 +2679,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild2.ancestorDNA ?? null, + )?.orgChild2?.ancestorDNA ?? null, child3: profile?.current_holders?.find( (x) => @@ -2697,7 +2697,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild3.ancestorDNA ?? null, + )?.orgChild3?.ancestorDNA ?? null, child4: profile?.current_holders?.find( (x) => @@ -2715,7 +2715,7 @@ export class OrganizationDotnetController extends Controller { (x) => x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, - )?.orgChild4.ancestorDNA ?? null, + )?.orgChild4?.ancestorDNA ?? null, posNo: shortName ?? "", }; }); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 6a2a9e4d..35e14f97 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4386,9 +4386,6 @@ export class ProfileController extends Controller { .andWhere(nodeCondition, { nodeId: nodeId, }) - // .andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, { - // orgRevisionId: revisionId, - // }) .orderBy("current_holders.posMasterNo", "ASC") .skip((page - 1) * pageSize) .take(pageSize) @@ -7303,6 +7300,7 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.positions", "positions") .leftJoinAndSelect("positions.posExecutive", "posExecutive") + .andWhere("profile.isLeave = false") .andWhere( _data.root != undefined && _data.root != null ? _data.root[0] != null diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 553477f4..e02c8584 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -67,6 +67,7 @@ import { ProfileLeave } from "../entities/ProfileLeave"; import permission from "../interfaces/permission"; import axios from "axios"; import { Position } from "../entities/Position"; +import { EmployeePosition } from "../entities/EmployeePosition"; @Route("api/v1/org/profile-employee") @Tags("ProfileEmployee") @Security("bearerAuth") @@ -108,6 +109,7 @@ export class ProfileEmployeeController extends Controller { private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private positionRepository = AppDataSource.getRepository(Position); + private employeePositionRepository = AppDataSource.getRepository(EmployeePosition); /** * report ประวัติแบบย่อ ลูกจ้าง @@ -1399,6 +1401,219 @@ export class ProfileEmployeeController extends Controller { return new HttpSuccess(formattedData); } + /** + * API รายการทะเบียนประวัติในระบบอื่น + * + * @summary ORG_065 - รายการทะเบียนประวัติในระบบอื่น + * + */ + @Get("otherSystem") + async listProfileNoPermission( + @Request() request: RequestWithUser, + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Query() + searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo", + @Query() searchKeyword: string = "", + @Query() posType?: string, + @Query() posLevel?: string, + @Query() yearLeave?: number, + @Query() isProbation?: boolean, + @Query() isRetire?: boolean, + @Query() nodeId?: string, + ) { + let queryLike = + "CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword"; + if (searchField == "citizenId") { + queryLike = "profileEmployee.citizenId LIKE :keyword"; + } else if (searchField == "position") { + queryLike = "profileEmployee.position LIKE :keyword"; + } else if (searchField == "posNo") { + queryLike = ` + CASE + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + END LIKE :keyword + `; + } + let posMaster = await this.posMasterRepo.findOne({ + where: { + current_holder: { keycloak: request.user.sub }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, + }); + let revisionId = ""; + if (nodeId == null) { + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + if (!findRevision) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); + } + revisionId = findRevision.id; + if (posMaster != null) nodeId = posMaster.orgRootId ?? ""; + } else { + const findRoot = await this.orgRootRepository.findOne({ + where: { id: nodeId }, + }); + if (!findRoot) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบสำนักงานนี้ในระบบ"); + } + revisionId = findRoot.orgRevisionId; + } + let nodeCondition = "current_holders.orgRootId = :nodeId"; + const [record, total] = await this.profileRepo + .createQueryBuilder("profileEmployee") + .leftJoinAndSelect("profileEmployee.posLevel", "posLevel") + .leftJoinAndSelect("profileEmployee.posType", "posType") + .leftJoinAndSelect("profileEmployee.current_holders", "current_holders") + .leftJoinAndSelect("current_holders.positions", "positions") + .leftJoinAndSelect("current_holders.orgRevision", "orgRevision") + .leftJoinAndSelect("current_holders.orgRoot", "orgRoot") + .leftJoinAndSelect("current_holders.orgChild1", "orgChild1") + .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") + .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") + .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: revisionId }) + .andWhere( + posType != undefined && posType != null && posType != "" + ? "posType.posTypeName LIKE :keyword1" + : "1=1", + { + keyword1: `${posType}`, + }, + ) + .andWhere( + posLevel != undefined && posLevel != null && posLevel != "" + ? "posLevel.posLevelName LIKE :keyword2" + : "1=1", + { + keyword2: `${posLevel}`, + }, + ) + .andWhere( + isProbation != undefined && isProbation != null + ? `profile.isProbation = ${isProbation}` + : "1=1", + ) + .andWhere( + isRetire != undefined && isRetire != null + ? isRetire == false + ? `profile.dateLeave IS null` + : `profile.dateLeave IS NOT NULL` + : "1=1", + ) + .andWhere( + searchKeyword != undefined && searchKeyword != null && searchKeyword != "" + ? queryLike + : "1=1", + { + keyword: `%${searchKeyword}%`, + }, + ) + .andWhere(nodeCondition, { + nodeId: nodeId, + }) + .orderBy("current_holders.posMasterNo", "ASC") + .skip((page - 1) * pageSize) + .take(pageSize) + .getManyAndCount(); + + const data = await Promise.all( + record.map((_data) => { + const shortName = + _data.current_holders.length == 0 + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 != null + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 != + null + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 != + null + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 != + null + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot != + null + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + : null; + const root = + _data.current_holders.length == 0 || + (_data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && + _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null) + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot; + + const child1 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == revisionId) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1; + + const child2 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == revisionId) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2; + + const child3 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == revisionId) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3; + + const child4 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == revisionId) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4; + + let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; + let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; + let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`; + let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; + + return { + id: _data.id, + avatar: _data.avatar, + avatarName: _data.avatarName, + prefix: _data.prefix, + rank: _data.rank, + firstName: _data.firstName, + lastName: _data.lastName, + citizenId: _data.citizenId, + posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName, + posType: _data.posType == null ? null : _data.posType.posTypeName, + posLevelId: _data.posLevel == null ? null : _data.posLevel.id, + posTypeId: _data.posType == null ? null : _data.posType.id, + position: _data.position, + posNo: shortName, + rootId: root == null ? null : root.id, + root: root == null ? null : root.orgRootName, + orgRootShortName: root == null ? null : root.orgRootShortName, + orgRevisionId: root == null ? null : root.orgRevisionId, + org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, + }; + }), + ); + + return new HttpSuccess({ data: data, total }); + } + /** * API Update amount * @@ -2201,8 +2416,7 @@ export class ProfileEmployeeController extends Controller { ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4; - const position = await this.positionRepository.findOne({ - relations: ["posExecutive"], + const position = await this.employeePositionRepository.findOne({ where: { posMasterId: posMaster?.id, }, @@ -2231,16 +2445,9 @@ export class ProfileEmployeeController 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, - posExecutivePriority: - position == null || position.posExecutive == null - ? null - : position.posExecutive.posExecutivePriority, - posExecutiveId: - position == null || position.posExecutive == null ? null : position.posExecutive.id, + posExecutiveName: null, + posExecutivePriority: null, + posExecutiveId: null, rootId: root == null ? null : root.id, rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, @@ -3015,6 +3222,7 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .andWhere("profile.isLeave = false") .andWhere( _data.root != undefined && _data.root != null ? _data.root[0] != null @@ -3279,10 +3487,6 @@ export class ProfileEmployeeController extends Controller { posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName, posTypeName: item.posType == null ? null : item.posType.posTypeName, posNo: `${posMaster == null ? null : posMaster.posMasterNo}${shortName}`, - // positionField: position == null ? null : position.positionField, - // positionArea: position == null ? null : position.positionArea, - // posExecutiveName: posExecutive, - // positionExecutiveField: position == null ? null : position.positionExecutiveField, isProbation: item.isProbation, orgRootName: item.current_holders == null || @@ -3729,7 +3933,6 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.positions", "positions") - // .leftJoinAndSelect("positions.posExecutive", "posExecutive") .where("YEAR(profileEmployee.dateRetire) = :year", { year }) .getMany(); @@ -3750,23 +3953,6 @@ export class ProfileEmployeeController extends Controller { item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id); - // const posExecutive = - // position == null || - // item.current_holders - // .find((x) => x.orgRevisionId == findRevision.id) - // ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive == - // null || - // item.current_holders - // .find((x) => x.orgRevisionId == findRevision.id) - // ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive - // ?.posExecutiveName == null - // ? null - // : item.current_holders - // .find((x) => x.orgRevisionId == findRevision.id) - // ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive - // .posExecutiveName; - // const posExecutiveId = - // position == null || position.posExecutive == null ? null : position.posExecutive.id; const shortName = item.current_holders.length == 0 @@ -3880,8 +4066,6 @@ export class ProfileEmployeeController extends Controller { posNo: shortName, posMasterNo: posMaster == null ? null : posMaster.posMasterNo, position: item.position, - // posExecutiveId: posExecutiveId, - // posExecutiveName: posExecutive, node: node, nodeId: nodeId, nodeShortName: nodeShortName, @@ -4536,12 +4720,6 @@ export class ProfileEmployeeController 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 shortName = profile.current_holders.length == 0 ? null @@ -4588,7 +4766,6 @@ export class ProfileEmployeeController extends Controller { posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank, posTypeShortName: profile.posType == null ? null : profile.posType.posTypeShortName, posTypeId: profile.posType == null ? null : profile.posType.id, - // posExecutiveName: "", rootId: root == null ? null : root.id, rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 90a77f81..68ae5b05 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -2565,6 +2565,7 @@ export class ProfileEmployeeTempController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .andWhere("profile.isLeave = false") .where("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%`, })