From eb5e25987431cf62163fbf7d356346bed8496884 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 6 Jun 2025 15:59:23 +0700 Subject: [PATCH] fix organization --- src/controllers/AssignController.ts | 24 +++++++---- src/controllers/EvaluateResultController.ts | 12 ++++-- src/controllers/ReportController.ts | 45 ++++++++++++--------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/src/controllers/AssignController.ts b/src/controllers/AssignController.ts index dfd6062..b7d7db1 100644 --- a/src/controllers/AssignController.ts +++ b/src/controllers/AssignController.ts @@ -641,14 +641,18 @@ export class AssignController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); } - const splitOc = await profileData.organization.split(" "); - const splitOcAmount = await splitOc.length; + // const splitOc = await profileData.organization.split(" "); + // const splitOcAmount = await splitOc.length; const profile = { ...profileData, name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`, Position: profileData.positionName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: profileData.orgChild2Name + ? (profileData.orgChild4Name ? profileData.orgChild4Name + " " : "") + + (profileData.orgChild3Name ? profileData.orgChild3Name + " " : "") + + (profileData.orgChild2Name ? profileData.orgChild2Name + " " : "") + : "-", + Department: profileData.orgChild1Name ?? "-", Oc: profileData.orgRootName, PositionAndLevel: profileData.positionName + profileData.positionLevelName, }; @@ -890,14 +894,18 @@ export class AssignController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); } - const splitOc = await profileData.organization.split(" "); - const splitOcAmount = await splitOc.length; + // const splitOc = await profileData.organization.split(" "); + // const splitOcAmount = await splitOc.length; const profile = { ...profileData, name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`, Position: profileData.positionName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: profileData.orgChild2Name + ? (profileData.orgChild4Name ? profileData.orgChild4Name + " " : "") + + (profileData.orgChild3Name ? profileData.orgChild3Name + " " : "") + + (profileData.orgChild2Name ? profileData.orgChild2Name + " " : "") + : "-", + Department: profileData.orgChild1Name ?? "-", Oc: profileData.orgRootName, PositionAndLevel: profileData.positionName + profileData.positionLevelName, }; diff --git a/src/controllers/EvaluateResultController.ts b/src/controllers/EvaluateResultController.ts index 5537219..5765c01 100644 --- a/src/controllers/EvaluateResultController.ts +++ b/src/controllers/EvaluateResultController.ts @@ -285,8 +285,8 @@ export class EvaluateResultController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); } - const splitOc = await experimenteeData.organization.split(" "); - const splitOcAmount = await splitOc.length; + // const splitOc = await experimenteeData.organization.split(" "); + // const splitOcAmount = await splitOc.length; const experimentee = await { ...experimenteeData, name: @@ -295,8 +295,12 @@ export class EvaluateResultController extends Controller { " " + experimenteeData.lastName, PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: experimenteeData.orgChild2Name + ? (experimenteeData.orgChild4Name ? experimenteeData.orgChild4Name + " " : "") + + (experimenteeData.orgChild3Name ? experimenteeData.orgChild3Name + " " : "") + + (experimenteeData.orgChild2Name ? experimenteeData.orgChild2Name + " " : "") + : "-", + Department: experimenteeData.orgChild1Name ?? "-", Oc: experimenteeData.orgRootName, }; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6c7a125..ead19a5 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -593,19 +593,22 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - const splitOc = await experimenteeData.organization.split(" "); - const splitOcAmount = await splitOc.length; - const organization = await experimenteeData.organization.replace(/\//g, " "); + // const splitOc = await experimenteeData.organization.split(" "); + // const splitOcAmount = await splitOc.length; + // const organization = await experimenteeData.organization.replace(/\//g, " "); const experimentee = await { ...experimenteeData, - organization: organization, name: `${experimenteeData.prefixName}${experimenteeData.firstName} ${experimenteeData.lastName}`, PositionLevelName: experimenteeData.positionLevelName, PositionLineName: experimenteeData.positionLineName, Position: experimenteeData.positionName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: experimenteeData.orgChild2Name + ? (experimenteeData.orgChild4Name ? experimenteeData.orgChild4Name + " " : "") + + (experimenteeData.orgChild3Name ? experimenteeData.orgChild3Name + " " : "") + + (experimenteeData.orgChild2Name ? experimenteeData.orgChild2Name + " " : "") + : "-", + Department: experimenteeData.orgChild1Name ?? "-", Oc: experimenteeData.orgRootName, PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName, }; @@ -836,19 +839,22 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - const splitOc = await experimenteeData.organization.split(" "); - const splitOcAmount = await splitOc.length; - const organization = await experimenteeData.organization.replace(/\//g, " "); + // const splitOc = await experimenteeData.organization.split(" "); + // const splitOcAmount = await splitOc.length; + // const organization = await experimenteeData.organization.replace(/\//g, " "); const experimentee = await { ...experimenteeData, - organization: organization, name: `${experimenteeData.prefixName}${experimenteeData.firstName} ${experimenteeData.lastName}`, PositionLevelName: experimenteeData.positionLevelName, PositionLineName: experimenteeData.positionLineName, Position: experimenteeData.positionName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: experimenteeData.orgChild2Name + ? (experimenteeData.orgChild4Name ? experimenteeData.orgChild4Name + " " : "") + + (experimenteeData.orgChild3Name ? experimenteeData.orgChild3Name + " " : "") + + (experimenteeData.orgChild2Name ? experimenteeData.orgChild2Name + " " : "") + : "-", + Department: experimenteeData.orgChild1Name ?? "-", Oc: experimenteeData.orgRootName, PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName, }; @@ -1112,19 +1118,22 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - const splitOc = await experimenteeData.organization.split(" "); - const splitOcAmount = await splitOc.length; - const organization = await experimenteeData.organization.replace(/\//g, " "); + // const splitOc = await experimenteeData.organization.split(" "); + // const splitOcAmount = await splitOc.length; + // const organization = await experimenteeData.organization.replace(/\//g, " "); const experimentee = await { ...experimenteeData, - organization: organization, name: `${experimenteeData.prefixName}${experimenteeData.firstName} ${experimenteeData.lastName}`, PositionLevelName: experimenteeData.positionLevelName, PositionLineName: experimenteeData.positionLineName, Position: experimenteeData.positionName, - Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-", - OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-", + OrganizationOrganization: experimenteeData.orgChild2Name + ? (experimenteeData.orgChild4Name ? experimenteeData.orgChild4Name + " " : "") + + (experimenteeData.orgChild3Name ? experimenteeData.orgChild3Name + " " : "") + + (experimenteeData.orgChild2Name ? experimenteeData.orgChild2Name + " " : "") + : "-", + Department: experimenteeData.orgChild1Name ?? "-", Oc: experimenteeData.orgRootName, PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName, };