diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index e4140d2a..a0f03194 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -309,6 +309,18 @@ export class ImportDataController extends Controller { "ADMIN_NAME", "REMARK", "ORDER_MOVE_POSITION", + "SAL_POS_AMOUNT_1", + "SAL_POS_AMOUNT_2", + "SPECIAL_AMT", + "MP_COMMAND_DATE", + "FLAG_TO_NAME_CODE", + "DEPARTMENT_NAME", + "DIVISION_NAME", + "SECTION_NAME", + "JOB_NAME", + "MP_CEE", + "USER_CREATE", + "USER_UPDATE", ], }); @@ -364,11 +376,11 @@ export class ImportDataController extends Controller { profileSalary.createdAt = item.USER_CREATE == "" ? new Date(item.USER_CREATE.replace(" +0700 +07:00", "")) - : null_; + : new Date(); profileSalary.lastUpdatedAt = item.USER_UPDATE == "" ? new Date(item.USER_UPDATE.replace(" +0700 +07:00", "")) - : null_; + : new Date(); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.salaryRepo.save(profileSalary); }), @@ -420,6 +432,18 @@ export class ImportDataController extends Controller { "ADMIN_NAME", "REMARK", "ORDER_MOVE_POSITION", + "SAL_POS_AMOUNT_1", + "SAL_POS_AMOUNT_2", + "SPECIAL_AMT", + "MP_COMMAND_DATE", + "FLAG_TO_NAME_CODE", + "DEPARTMENT_NAME", + "DIVISION_NAME", + "SECTION_NAME", + "JOB_NAME", + "MP_CEE", + "USER_CREATE", + "USER_UPDATE", ], }); @@ -476,11 +500,11 @@ export class ImportDataController extends Controller { profileSalary.createdAt = item.USER_CREATE == "" ? new Date(item.USER_CREATE.replace(" +0700 +07:00", "")) - : null_; + : new Date(); profileSalary.lastUpdatedAt = item.USER_UPDATE == "" ? new Date(item.USER_UPDATE.replace(" +0700 +07:00", "")) - : null_; + : new Date(); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.salaryRepo.save(profileSalary); }), diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 5d610eaa..e8d6acad 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -232,7 +232,14 @@ export class ProfileController extends Controller { "refCommandNo", "amount", "templateDoc", - "positionLine", + "position", + "orgRoot", + "orgChild1", + "orgChild2", + "orgChild3", + "orgChild4", + "mpCee", + "positionExecutive", ], where: { profileId: id }, order: { date: "ASC" }, @@ -242,24 +249,28 @@ export class ProfileController extends Controller { salary_raw.length > 1 ? salary_raw.slice(1).map((item) => ({ date: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) : null, - positionLine: item.positionLine != null ? item.positionLine : "-", + position: item.position != null ? item.position : "-", posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, orgRoot: item.orgRoot, orgChild1: item.orgChild1, orgChild2: item.orgChild2, orgChild3: item.orgChild3, orgChild4: item.orgChild4, + mpCee: item.mpCee, + positionExecutive: item.positionExecutive, })) : [ { date: "-", - positionLine: "-", + position: "-", posNo: "-", orgRoot: null, orgChild1: null, orgChild2: null, orgChild3: null, orgChild4: null, + mpCee: null, + positionExecutive: null, }, ]; @@ -292,55 +303,63 @@ export class ProfileController extends Controller { prefix: profile.prefix != null ? profile.prefix : null, firstName: profile.firstName != null ? profile.firstName : null, lastName: profile.lastName != null ? profile.lastName : null, - citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-", + citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) - : "-", + : "", dateRetire: profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) - : "-", + : "", salaryAmount: - profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", + profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "", registrationAddress: Extension.ToThaiNumber( `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, ), date: salary_raw.length > 0 && salary_raw[0].date != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate(salary_raw[0].date)) - : "-", - positionName: profile.position != null ? profile.position : "-", + : "", + positionName: profile.position != null ? profile.position : "", appointText: profile.dateAppoint != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profile.dateAppoint)) - : "-", + : "", posNo: salary_raw.length > 0 && salary_raw[0].posNo != null ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].posNo)) - : "-", + : "", position: salary_raw.length > 0 && salary_raw[0].position != null ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].position)) - : "-", + : "", + mpCee: + salary_raw.length > 0 && salary_raw[0].mpCee != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].mpCee)) + : "", + positionExecutive: + salary_raw.length > 0 && salary_raw[0].positionExecutive != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].positionExecutive)) + : "", org: `${ - salary_raw.length > 0 && salary_raw[0].orgChild4 != null + salary_raw.length > 0 && salary_raw[0].orgChild4 && salary_raw[0].orgChild4 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild4)) + " " : "" }${ - salary_raw.length > 0 && salary_raw[0].orgChild3 != null + salary_raw.length > 0 && salary_raw[0].orgChild3 && salary_raw[0].orgChild3 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild3)) + " " : "" }${ - salary_raw.length > 0 && salary_raw[0].orgChild2 != null + salary_raw.length > 0 && salary_raw[0].orgChild2 && salary_raw[0].orgChild2 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild2)) + " " : "" }${ - salary_raw.length > 0 && salary_raw[0].orgChild1 != null + salary_raw.length > 0 && salary_raw[0].orgChild1 && salary_raw[0].orgChild1 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild1)) + " " : "" }${ - salary_raw.length > 0 && salary_raw[0].orgRoot != null + salary_raw.length > 0 && salary_raw[0].orgRoot && salary_raw[0].orgRoot != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) : "" }`, @@ -349,7 +368,7 @@ export class ProfileController extends Controller { salarys: salarys.map((item) => { return { ...item, - org: `${item.orgChild4 != null ? item.orgChild4 + " " : ""}${item.orgChild3 != null ? item.orgChild3 + " " : ""}${item.orgChild2 != null ? item.orgChild2 + " " : ""}${item.orgChild1 != null ? item.orgChild1 + " " : ""}${item.orgRoot != null ? item.orgRoot + " " : ""}`, + org: `${item.orgChild4 && item.orgChild4 != "-" ? item.orgChild4 + " " : ""}${item.orgChild3 && item.orgChild3 != "-" ? item.orgChild3 + " " : ""}${item.orgChild2 && item.orgChild2 != "-" ? item.orgChild2 + " " : ""}${item.orgChild1 && item.orgChild1 != "-" ? item.orgChild1 + " " : ""}${item.orgRoot && item.orgRoot != "-" ? item.orgRoot + " " : ""}`, }; }), url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 7563ed27..10ff5e45 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -225,6 +225,58 @@ export class ProfileEmployeeController extends Controller { let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; + const salary_raw = await this.salaryRepo.find({ + select: [ + "date", + "position", + "posNo", + "positionType", + "positionLevel", + "positionSalaryAmount", + "refCommandNo", + "amount", + "templateDoc", + "position", + "orgRoot", + "orgChild1", + "orgChild2", + "orgChild3", + "orgChild4", + "mpCee", + "positionExecutive", + ], + where: { profileEmployeeId: id }, + order: { date: "ASC" }, + }); + const salarys = + salary_raw.length > 1 + ? salary_raw.slice(1).map((item) => ({ + date: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) : null, + position: item.position != null ? item.position : "-", + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, + orgRoot: item.orgRoot, + orgChild1: item.orgChild1, + orgChild2: item.orgChild2, + orgChild3: item.orgChild3, + orgChild4: item.orgChild4, + mpCee: item.mpCee, + positionExecutive: item.positionExecutive, + })) + : [ + { + date: "-", + position: "-", + posNo: "-", + orgRoot: null, + orgChild1: null, + orgChild2: null, + orgChild3: null, + orgChild4: null, + mpCee: null, + positionExecutive: null, + }, + ]; + const educations = await this.profileEducationRepo.find({ select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], where: { profileEmployeeId: id }, @@ -254,19 +306,19 @@ export class ProfileEmployeeController extends Controller { prefix: profile.prefix != null ? profile.prefix : null, firstName: profile.firstName != null ? profile.firstName : null, lastName: profile.lastName != null ? profile.lastName : null, - citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-", + citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) - : "-", + : "", dateRetire: profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) - : "-", + : "", salaryAmount: profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) - : "-", + : "", registrationAddress: Extension.ToThaiNumber( `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, ), @@ -275,14 +327,57 @@ export class ProfileEmployeeController extends Controller { ? Extension.ToThaiNumber( Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date), ) - : "-", - positionName: profile.position != null ? profile.position : "-", + : "", + positionName: profile.position != null ? profile.position : "", appointText: profile.dateAppoint != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint)) - : "-", + : "", + posNo: + salary_raw.length > 0 && salary_raw[0].posNo != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].posNo)) + : "", + position: + salary_raw.length > 0 && salary_raw[0].position != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].position)) + : "", + mpCee: + salary_raw.length > 0 && salary_raw[0].mpCee != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].mpCee)) + : "", + positionExecutive: + salary_raw.length > 0 && salary_raw[0].positionExecutive != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].positionExecutive)) + : "", + org: `${ + salary_raw.length > 0 && salary_raw[0].orgChild4 && salary_raw[0].orgChild4 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild4)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild3 && salary_raw[0].orgChild3 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild3)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild2 && salary_raw[0].orgChild2 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild2)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild1 && salary_raw[0].orgChild1 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild1)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgRoot && salary_raw[0].orgRoot != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) + : "" + }`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, educations: Education, + salarys: salarys.map((item) => { + return { + ...item, + org: `${item.orgChild4 && item.orgChild4 != "-" ? item.orgChild4 + " " : ""}${item.orgChild3 && item.orgChild3 != "-" ? item.orgChild3 + " " : ""}${item.orgChild2 && item.orgChild2 != "-" ? item.orgChild2 + " " : ""}${item.orgChild1 && item.orgChild1 != "-" ? item.orgChild1 + " " : ""}${item.orgRoot && item.orgRoot != "-" ? item.orgRoot + " " : ""}`, + }; + }), url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, }; diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 23843010..da672bab 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -222,6 +222,56 @@ export class ProfileEmployeeTempController extends Controller { let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; + const salary_raw = await this.salaryRepo.find({ + select: [ + "date", + "position", + "posNo", + "positionType", + "positionLevel", + "positionSalaryAmount", + "refCommandNo", + "amount", + "templateDoc", + "orgRoot", + "orgChild1", + "orgChild2", + "orgChild3", + "orgChild4", + "mpCee", + "positionExecutive", + ], + where: { profileEmployeeId: id }, + order: { date: "ASC" }, + }); + const salarys = + salary_raw.length > 1 + ? salary_raw.slice(1).map((item) => ({ + date: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) : null, + position: item.position != null ? item.position : "-", + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, + orgRoot: item.orgRoot, + orgChild1: item.orgChild1, + orgChild2: item.orgChild2, + orgChild3: item.orgChild3, + orgChild4: item.orgChild4, + mpCee: item.mpCee, + positionExecutive: item.positionExecutive, + })) + : [ + { + date: "-", + position: "-", + posNo: "-", + orgRoot: null, + orgChild1: null, + orgChild2: null, + orgChild3: null, + orgChild4: null, + mpCee: null, + positionExecutive: null, + }, + ]; const educations = await this.profileEducationRepo.find({ select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], where: { profileEmployeeId: id }, @@ -251,19 +301,19 @@ export class ProfileEmployeeTempController extends Controller { prefix: profile.prefix != null ? profile.prefix : null, firstName: profile.firstName != null ? profile.firstName : null, lastName: profile.lastName != null ? profile.lastName : null, - citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-", + citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) - : "-", + : "", dateRetire: profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) - : "-", + : "", salaryAmount: profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) - : "-", + : "", registrationAddress: Extension.ToThaiNumber( `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, ), @@ -272,14 +322,57 @@ export class ProfileEmployeeTempController extends Controller { ? Extension.ToThaiNumber( Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date), ) - : "-", - positionName: profile.position != null ? profile.position : "-", + : "", + positionName: profile.position != null ? profile.position : "", appointText: profile.dateAppoint != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint)) - : "-", + : "", + posNo: + salary_raw.length > 0 && salary_raw[0].posNo != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].posNo)) + : "", + position: + salary_raw.length > 0 && salary_raw[0].position != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].position)) + : "", + mpCee: + salary_raw.length > 0 && salary_raw[0].mpCee != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].mpCee)) + : "", + positionExecutive: + salary_raw.length > 0 && salary_raw[0].positionExecutive != null + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].positionExecutive)) + : "", + org: `${ + salary_raw.length > 0 && salary_raw[0].orgChild4 && salary_raw[0].orgChild4 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild4)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild3 && salary_raw[0].orgChild3 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild3)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild2 && salary_raw[0].orgChild2 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild2)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild1 && salary_raw[0].orgChild1 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild1)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgRoot && salary_raw[0].orgRoot != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) + : "" + }`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, educations: Education, + salarys: salarys.map((item) => { + return { + ...item, + org: `${item.orgChild4 && item.orgChild4 != "-" ? item.orgChild4 + " " : ""}${item.orgChild3 && item.orgChild3 != "-" ? item.orgChild3 + " " : ""}${item.orgChild2 && item.orgChild2 != "-" ? item.orgChild2 + " " : ""}${item.orgChild1 && item.orgChild1 != "-" ? item.orgChild1 + " " : ""}${item.orgRoot && item.orgRoot != "-" ? item.orgRoot + " " : ""}`, + }; + }), url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, };