diff --git a/src/controllers/DevelopmentRequestController.ts b/src/controllers/DevelopmentRequestController.ts index 28fbef4d..b02b6bf0 100644 --- a/src/controllers/DevelopmentRequestController.ts +++ b/src/controllers/DevelopmentRequestController.ts @@ -263,6 +263,7 @@ export class DevelopmentRequestController extends Controller { sysName: "REGISTRY_IDP", posLevelName: profile.posLevel.posLevelName, posTypeName: profile.posType.posTypeName, + fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}` }) .catch((error) => { console.error("Error calling API:", error); diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index d3d70b0c..4b6ef89f 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -888,6 +888,31 @@ export class EmployeePositionController extends Controller { await this.employeePositionRepository.save(position, { data: request }); }), ); + + if (posMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: posMaster.current_holderId, + }, + }); + if (profile != null) { + const positionNew = await this.employeePositionRepository.findOne({ + where: { + // positionIsSelected: true, + posMasterId: posMaster.id, + }, + }); + if (positionNew != null) { + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + profile.employeeOc = posMaster?.orgRoot?.orgRootName ?? null; + profile.positionEmployeePositionId = positionNew.positionName; + + await this.profileRepository.save(profile); + } + } + } return new HttpSuccess(posMaster.id); } @@ -2242,6 +2267,23 @@ export class EmployeePositionController extends Controller { if (!dataMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); } + if (dataMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: dataMaster.current_holderId, + }, + }); + const _null: any = null; + if (profile != null) { + profile.posLevelId = _null; + profile.posTypeId = _null; + profile.position = _null; + profile.employeeOc = _null; + profile.positionEmployeePositionId = _null; + await this.profileRepository.save(profile); + } + } + await this.employeePosMasterRepository.update(id, { isSit: false, next_holderId: null, diff --git a/src/controllers/EmployeeTempPositionController.ts b/src/controllers/EmployeeTempPositionController.ts index 46939932..b551fa95 100644 --- a/src/controllers/EmployeeTempPositionController.ts +++ b/src/controllers/EmployeeTempPositionController.ts @@ -689,6 +689,31 @@ export class EmployeeTempPositionController extends Controller { await this.employeePositionRepository.save(position, { data: request }); }), ); + + if (posMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: posMaster.current_holderId, + }, + }); + if (profile != null) { + const positionNew = await this.employeePositionRepository.findOne({ + where: { + // positionIsSelected: true, + posMasterId: posMaster.id, + }, + }); + if (positionNew != null) { + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + profile.employeeOc = posMaster?.orgRoot?.orgRootName ?? null; + profile.positionEmployeePositionId = positionNew.positionName; + + await this.profileRepository.save(profile); + } + } + } return new HttpSuccess(posMaster.id); } @@ -1966,6 +1991,23 @@ export class EmployeeTempPositionController extends Controller { if (!dataMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); } + if (dataMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: dataMaster.current_holderId, + }, + }); + const _null: any = null; + if (profile != null) { + profile.posLevelId = _null; + profile.posTypeId = _null; + profile.position = _null; + profile.employeeOc = _null; + profile.positionEmployeePositionId = _null; + await this.profileRepository.save(profile); + } + } + await this.employeeTempPosMasterRepository.update(id, { isSit: false, next_holderId: null, diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index a0cf74a7..adabac98 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -639,6 +639,36 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgRoot?.ancestorDNA ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.ancestorDNA ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.ancestorDNA ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.ancestorDNA ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.ancestorDNA ?? null, commander: fullname, commanderPositionName, commanderId, @@ -965,6 +995,36 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgRoot?.ancestorDNA ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.ancestorDNA ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.ancestorDNA ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.ancestorDNA ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.ancestorDNA ?? null, commander: fullname, commanderPositionName, commanderId, @@ -2875,6 +2935,7 @@ export class OrganizationDotnetController extends Controller { rootId: root == null ? null : root.id, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, + rootDnaId: root == null ? null : root.ancestorDNA, }; return new HttpSuccess(_profile); } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d3d9d340..f63e779b 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1615,7 +1615,7 @@ export class ProfileController extends Controller { ).toLocaleString(), ) : ""; - const fullCurrentAddress = profiles + const fullCurrentAddress = profiles && profiles.currentAddress ? Extension.ToThaiNumber( profiles.currentAddress + " ตำบล/แขวง " + @@ -1627,7 +1627,7 @@ export class ProfileController extends Controller { profiles.currentZipCode, ) : ""; - const fullRegistrationAddress = profiles + const fullRegistrationAddress = profiles && profiles.registrationAddress ? Extension.ToThaiNumber( profiles.registrationAddress + " ตำบล/แขวง " + @@ -5859,12 +5859,10 @@ export class ProfileController extends Controller { _data.profileSalary[0].positionExecutive == null ? null : _data.profileSalary[0].positionExecutive, - posNo: - _data.profileSalary[0].posNoAbb == "" - ? "" - : _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == "" - ? "" - : _data.profileSalary[0].posNo, + posNo: + _data.profileSalary[0].posNoAbb && _data.profileSalary[0].posNo + ? _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo + : _data.profileSalary[0].posNo || "", rootId: null, root: _data.profileSalary[0].orgRoot == null ? null : _data.profileSalary[0].orgRoot, orgRootShortName: diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index b8cec66d..605e141f 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -230,6 +230,7 @@ export class ProfileEditController extends Controller { sysName: "REGISTRY_PROFILE", posLevelName: profile.posLevel.posLevelName, posTypeName: profile.posType.posTypeName, + fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}` }) .catch((error) => { console.error("Error calling API:", error); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 5b845a59..53ac9f1b 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2031,12 +2031,10 @@ export class ProfileEmployeeController extends Controller { positionId: _data.positionIdTemp, posmasterId: _data.posmasterIdTemp, position: _data.position, - posNo: - _data.profileSalary[0].posNoAbb == "" - ? "" - : _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == "" - ? "" - : _data.profileSalary[0].posNo, + posNo: + _data.profileSalary[0].posNoAbb && _data.profileSalary[0].posNo + ? _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo + : _data.profileSalary[0].posNo || "", employeeClass: _data.employeeClass == null ? null : _data.employeeClass, govAge: Extension.CalculateGovAge(_data.dateAppoint, 0, 0), age: Extension.CalculateAgeStrV2(_data.birthDate, 0, 0), diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 6c477858..722da33b 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -50,6 +50,7 @@ export class WorkflowController extends Controller { sysName: string; posLevelName: string; posTypeName: string; + fullName?: string|null }, ) { let profileType = "OFFICER"; @@ -199,8 +200,10 @@ export class WorkflowController extends Controller { })); await new CallAPI() .PostData(req, "/placement/noti/profiles", { - subject: `รายการถูกส่ง`, - body: `รายการถูกส่ง`, + // subject: `รายการถูกส่ง`, + // body: `รายการถูกส่ง`, + subject: `แจ้ง${workflow.name}ของ ${body.fullName}`, + body: `แจ้ง${workflow.name}ของ ${body.fullName}`, receiverUserIds: profileNow, payload: "", //แนบไฟล์ isSendMail: true,