diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 6e5e638b..a9b68243 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -3056,18 +3056,23 @@ export class OrganizationDotnetController extends Controller { posExecutiveId: position == null || position.posExecutive == null ? null : position.posExecutive.id, rootId: root == null ? null : root.id, + rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, child1Id: child1 == null ? null : child1.id, + child1DnaId: child1 == null ? null : child1.ancestorDNA, child1: child1 == null ? null : child1.orgChild1Name, child1ShortName: child1 == null ? null : child1.orgChild1ShortName, child2Id: child2 == null ? null : child2.id, + child2DnaId: child2 == null ? null : child2.ancestorDNA, child2: child2 == null ? null : child2.orgChild2Name, child2ShortName: child2 == null ? null : child2.orgChild2ShortName, child3Id: child3 == null ? null : child3.id, + child3DnaId: child3 == null ? null : child3.ancestorDNA, child3: child3 == null ? null : child3.orgChild3Name, child3ShortName: child3 == null ? null : child3.orgChild3ShortName, child4Id: child4 == null ? null : child4.id, + child4DnaId: child4 == null ? null : child4.ancestorDNA, child4: child4 == null ? null : child4.orgChild4Name, child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, @@ -4216,17 +4221,19 @@ export class OrganizationDotnetController extends Controller { const _position = position.length > 0 ? position[0] : []; const mapEmpProfile = { - birthDate: profile.birthDate ?? null, - retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null, - govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "", - age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "", - dateAppoint: profile.dateAppoint, - amount: profile.amount, - telephoneNumber: profile.telephoneNumber ?? null, - positionName: profile.position, + birthDate: profile.birthDate ?? "-", + retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : "-", + govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "-", + age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "-", + dateAppoint: profile.dateAppoint ?? "-", + dateCurrent: new Date(), + amount: profile.amount ?? "-", + telephoneNumber: profile.telephoneNumber ?? "-", + positionName: profile.position ?? "-", posLevel: profile.posType && profile.posLevel - ? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}` : null, - posType: profile.posType?.posTypeName ?? null, + ? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}` + : "-", + posType: profile.posType?.posTypeName ?? "-", currentAddress: profile && profile.currentAddress ? profile.currentAddress + (profile.currentSubDistrict && profile.currentSubDistrict.name @@ -4236,8 +4243,8 @@ export class OrganizationDotnetController extends Controller { (profile.currentProvince && profile.currentProvince.name ? " จังหวัด " + profile.currentProvince.name : "") + profile.currentZipCode - : "", - oc: oc, + : "-", + oc: oc ?? "-", root: profile?.current_holders?.find( (x) => @@ -4269,9 +4276,12 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4?.orgChild4Name ?? null, positions: _position && _position.length > 0 - ? _position.map((x:any) => ({ + ? _position + .slice(0, -1) + .map((x:any, idx: number) => ({ positionName: x.positionName, - date: x.commandDateAffect, + dateStart: x.commandDateAffect ?? null, + dateEnd: _position[idx + 1]?.commandDateAffect ?? null, positionType: x.positionType, positionLevel: x.positionLevel, orgRoot: x.orgRoot, @@ -4284,9 +4294,9 @@ export class OrganizationDotnetController extends Controller { educations: profile.profileEducations && profile.profileEducations.length > 0 ? profile.profileEducations.map(x => ({ educationLevel: x.educationLevel, - institute: x.institute, - country: x.country, - finishDate: x.finishDate, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate ?? "-", })) : [] }; @@ -4315,16 +4325,17 @@ export class OrganizationDotnetController extends Controller { const _position = position.length > 0 ? position[0] : []; const mapProfile = { - birthDate: profile.birthDate ?? null, - retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null, - govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "", - age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "", - dateAppoint: profile.dateAppoint, - amount: profile.amount, - telephoneNumber: profile.telephoneNumber ?? null, - positionName: profile.position, - posLevel: profile.posLevel?.posLevelName ?? null, - posType: profile.posType?.posTypeName ?? null, + birthDate: profile.birthDate ?? "-", + retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : "-", + govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "-", + age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "-", + dateAppoint: profile.dateAppoint ?? "-", + dateCurrent: new Date(), + amount: profile.amount ?? "-", + telephoneNumber: profile.telephoneNumber ?? "-", + positionName: profile.position ?? "-", + posLevel: profile.posLevel?.posLevelName ?? "-", + posType: profile.posType?.posTypeName ?? "-", currentAddress: profile && profile.currentAddress ? profile.currentAddress + (profile.currentSubDistrict && profile.currentSubDistrict.name @@ -4334,8 +4345,8 @@ export class OrganizationDotnetController extends Controller { (profile.currentProvince && profile.currentProvince.name ? " จังหวัด " + profile.currentProvince.name : "") + profile.currentZipCode - : "", - oc: oc, + : "-", + oc: oc ?? "-", root: profile?.current_holders?.find( (x) => @@ -4367,9 +4378,12 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4?.orgChild4Name ?? null, positions: _position && _position.length > 0 - ? _position.map((x:any) => ({ + ? _position + .slice(0, -1) + .map((x:any, idx: number) => ({ positionName: x.positionName, - date: x.commandDateAffect, + dateStart: x.commandDateAffect ?? null, + dateEnd: _position[idx + 1]?.commandDateAffect ?? null, positionType: x.positionType, positionLevel: x.positionLevel, orgRoot: x.orgRoot, @@ -4382,9 +4396,9 @@ export class OrganizationDotnetController extends Controller { educations: profile.profileEducations && profile.profileEducations.length > 0 ? profile.profileEducations.map(x => ({ educationLevel: x.educationLevel, - institute: x.institute, - country: x.country, - finishDate: x.finishDate, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate ?? "-", })) : [] };