From 479e9a3938ad4cc8224f8bb0e1dddf848e712f69 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 8 Jan 2025 14:15:28 +0700 Subject: [PATCH] save profile salary --- src/controllers/CommandController.ts | 202 ++++++++++- src/controllers/ImportDataController.ts | 76 +++- src/controllers/ProfileController.ts | 333 +++++++++++++----- src/controllers/ProfileEmployeeController.ts | 4 +- .../ProfileEmployeeTempController.ts | 4 +- src/controllers/ProfileSalaryController.ts | 15 +- .../ProfileSalaryEmployeeController.ts | 17 +- .../ProfileSalaryEmployeeTempController.ts | 2 + src/entities/CommandType.ts | 8 + src/entities/HR_POSITION_OFFICER.ts | 84 +++++ src/entities/ProfileSalary.ts | 99 ++++++ src/entities/ProfileSalaryHistory.ts | 89 +++++ src/interfaces/functionMain.ts | 1 + src/services/rabbitmq.ts | 12 +- 14 files changed, 817 insertions(+), 129 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 5ddb2f43..8446fd6b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2200,6 +2200,14 @@ export class CommandController extends Controller { posmasterId: string; positionId: string; commandId?: string | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2225,6 +2233,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, { ...item, ...meta }); @@ -2322,6 +2331,14 @@ export class CommandController extends Controller { posmasterId: string; positionId: string; commandId?: string | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2347,6 +2364,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, { @@ -2459,6 +2477,14 @@ export class CommandController extends Controller { dateLeave?: Date | null; commandId?: string | null; isGovernment?: boolean | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2490,6 +2516,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, { ...item, ...meta }); @@ -2600,6 +2627,14 @@ export class CommandController extends Controller { dateLeave?: Date | null; isGovernment?: boolean | null; commandId?: string | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2628,6 +2663,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, { @@ -2700,6 +2736,14 @@ export class CommandController extends Controller { leaveReason?: string | null; dateLeave?: Date | null; isLeave?: boolean; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2728,6 +2772,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; if (item.isLeave != undefined && item.isLeave == true) { await removeProfileInOrganize(profile.id, "OFFICER"); @@ -2783,6 +2828,14 @@ export class CommandController extends Controller { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2808,6 +2861,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, { @@ -2843,7 +2897,6 @@ export class CommandController extends Controller { isLeave: boolean | null; leaveReason?: string | null; dateLeave?: Date | null; - refCommandDate?: Date | null; detail?: string | null; level?: string | null; unStigma?: string | null; @@ -2852,6 +2905,9 @@ export class CommandController extends Controller { positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; isGovernment?: boolean | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -2887,6 +2943,13 @@ export class CommandController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2929,10 +2992,10 @@ export class CommandController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -2942,6 +3005,11 @@ export class CommandController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -2949,7 +3017,10 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), dateGovernment: new Date(), + refCommandDate: new Date(), isGovernment: item.isGovernment, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, }; Object.assign(data, meta); @@ -3056,6 +3127,13 @@ export class CommandController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3098,7 +3176,7 @@ export class CommandController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", + posNo: shortName ? shortName : null, // positionLine: position?.positionField ?? "-", // positionPathSide: position?.positionArea ?? "-", // positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", @@ -3111,6 +3189,11 @@ export class CommandController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -3118,7 +3201,10 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), dateGovernment: new Date(), + refCommandDate: new Date(), isGovernment: item.isGovernment, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, }; Object.assign(data, meta); @@ -3220,7 +3306,6 @@ export class CommandController extends Controller { isLeave: boolean | null; leaveReason?: string | null; dateLeave?: Date | null; - refCommandDate?: Date | null; detail?: string | null; level?: string | null; unStigma?: string | null; @@ -3229,6 +3314,9 @@ export class CommandController extends Controller { positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; isGovernment?: boolean | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -3263,6 +3351,13 @@ export class CommandController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3304,7 +3399,7 @@ export class CommandController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", + posNo: shortName ? shortName : null, // positionLine: position?.positionField ?? "-", // positionPathSide: position?.positionArea ?? "-", // positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", @@ -3317,6 +3412,11 @@ export class CommandController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -3324,7 +3424,10 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), dateGovernment: new Date(), + refCommandDate: new Date(), isGovernment: item.isGovernment, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, }; Object.assign(data, meta); @@ -3426,6 +3529,9 @@ export class CommandController extends Controller { amount?: Double | null; positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -3461,6 +3567,13 @@ export class CommandController extends Controller { }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3502,10 +3615,10 @@ export class CommandController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -3515,12 +3628,20 @@ export class CommandController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, }; Object.assign(data, meta); const history = new ProfileSalaryHistory(); @@ -3563,6 +3684,9 @@ export class CommandController extends Controller { positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; isGovernment?: boolean | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -3614,6 +3738,13 @@ export class CommandController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3654,9 +3785,9 @@ export class CommandController extends Controller { positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, posNo: shortName, - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -3666,6 +3797,11 @@ export class CommandController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -3673,7 +3809,10 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), dateGovernment: new Date(), + refCommandDate: new Date(), isGovernment: item.isGovernment, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, }); await removeProfileInOrganize(profile.id, "OFFICER"); const clearProfile = await checkCommandType(String(item.commandId)); @@ -3736,6 +3875,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; const _null: any = null; if (item.bodyProfile.posLevelId === "") item.bodyProfile.posLevelId = null; @@ -4031,9 +4171,12 @@ export class CommandController extends Controller { commandYear: number; templateDoc: string | null; amount: Double | null; - amountSpecial: Double | null; + amountSpecial?: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -4072,12 +4215,20 @@ export class CommandController extends Controller { refCommandNo: `${item.commandNo}/${Extension.ToThaiYear(item.commandYear)}`, templateDoc: item.templateDoc, order: dest_item == null ? 1 : dest_item.order + 1, + // orgRoot: orgRootRef?.orgRootName??null, + // orgChild1: orgChild1Ref?.orgChild1Name??null, + // orgChild2: orgChild2Ref?.orgChild2Name??null, + // orgChild3: orgChild3Ref?.orgChild3Name??null, + // orgChild4: orgChild4Ref?.orgChild4Name??null, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, meta); @@ -4226,6 +4377,9 @@ export class CommandController extends Controller { amountSpecial?: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -4376,6 +4530,9 @@ export class CommandController extends Controller { amountSpecial?: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }[]; }, ) { @@ -4398,6 +4555,11 @@ export class CommandController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบตำแหน่งดังกล่าว"); } if (posMaster.next_holderId != null) { + const orgRootRef = posMaster?.orgRoot ?? null; + const orgChild1Ref = posMaster?.orgChild1 ?? null; + const orgChild2Ref = posMaster?.orgChild2 ?? null; + const orgChild3Ref = posMaster?.orgChild3 ?? null; + const orgChild4Ref = posMaster?.orgChild4 ?? null; const shortName = posMaster != null && posMaster.orgChild4 != null ? `${posMaster.orgChild4.orgChild4ShortName}${posMaster.posMasterNo}` @@ -4441,12 +4603,20 @@ export class CommandController extends Controller { refCommandNo: `${item.commandNo}/${Extension.ToThaiYear(item.commandYear)}`, templateDoc: item.templateDoc, order: dest_item == null ? 1 : dest_item.order + 1, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, + refCommandCode: item.refCommandCode, + refCommandName: item.refCommandName, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), }; Object.assign(data, meta); const history = new ProfileSalaryHistory(); diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index ee607745..55adddf7 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -46,7 +46,7 @@ export class ImportDataController extends Controller { private profileFamilyCoupleRepository = AppDataSource.getRepository(ProfileFamilyCouple); private profileFamilyMotherRepository = AppDataSource.getRepository(ProfileFamilyMother); private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); - private salaryRepository = AppDataSource.getRepository(ProfileSalary); + private salaryRepo = AppDataSource.getRepository(ProfileSalary); private profileRepo = AppDataSource.getRepository(Profile); private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee); private posLevelRepo = AppDataSource.getRepository(PosLevel); @@ -323,14 +323,36 @@ export class ImportDataController extends Controller { const SALARY: any = item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY); profileSalary.amount = SALARY; + const SAL_POS_AMOUNT_1: any = + item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == "" + ? null_ + : Number(item.SAL_POS_AMOUNT_1); + const SAL_POS_AMOUNT_2: any = + item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == "" + ? null_ + : Number(item.SAL_POS_AMOUNT_2); + profileSalary.positionSalaryAmount = SAL_POS_AMOUNT_1 ?? SAL_POS_AMOUNT_2; + const SPECIAL_AMT: any = + item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? null_ : Number(item.SPECIAL_AMT); + profileSalary.amountSpecial = SPECIAL_AMT; profileSalary.profileId = _item.id; profileSalary.refCommandNo = item.MP_COMMAND_NUM; profileSalary.posNo = item.POS_NUM_NAME + item.POS_NUM_CODE; - profileSalary.position = item.FLAG_TO_NAME; - profileSalary.positionLine = item.WORK_LINE_NAME; + profileSalary.position = item.WORK_LINE_NAME; profileSalary.positionPathSide = item.SPECIALIST_NAME; profileSalary.positionExecutive = item.ADMIN_NAME; profileSalary.templateDoc = item.REMARK; + profileSalary.refCommandDate = + item.MP_COMMAND_DATE == "" + ? null_ + : new Date(item.MP_COMMAND_DATE.replace(" +0700 +07:00", "")); + profileSalary.refCommandCode = item.FLAG_TO_NAME_CODE; + profileSalary.refCommandName = item.FLAG_TO_NAME; + profileSalary.orgRoot = item.DEPARTMENT_NAME; + profileSalary.orgChild1 = item.DIVISION_NAME; + profileSalary.orgChild2 = item.SECTION_NAME; + profileSalary.orgChild3 = item.JOB_NAME; + profileSalary.mpCee = item.MP_CEE; const ORDER_MOVE_POSITION: any = item.ORDER_MOVE_POSITION == null || item.ORDER_MOVE_POSITION == "" ? null_ @@ -340,10 +362,16 @@ export class ImportDataController extends Controller { profileSalary.createdFullName = request.user.name; profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateFullName = request.user.name; - profileSalary.createdAt = new Date(); - profileSalary.lastUpdatedAt = new Date(); + profileSalary.createdAt = + item.USER_CREATE == "" + ? null_ + : new Date(item.USER_CREATE.replace(" +0700 +07:00", "")); + profileSalary.lastUpdatedAt = + item.USER_UPDATE == "" + ? null_ + : new Date(item.USER_UPDATE.replace(" +0700 +07:00", "")); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); - await this.salaryRepository.save(profileSalary); + await this.salaryRepo.save(profileSalary); }), ); }), @@ -407,14 +435,36 @@ export class ImportDataController extends Controller { const SALARY: any = item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY); profileSalary.amount = SALARY; + const SAL_POS_AMOUNT_1: any = + item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == "" + ? null_ + : Number(item.SAL_POS_AMOUNT_1); + const SAL_POS_AMOUNT_2: any = + item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == "" + ? null_ + : Number(item.SAL_POS_AMOUNT_2); + profileSalary.positionSalaryAmount = SAL_POS_AMOUNT_1 ?? SAL_POS_AMOUNT_2; + const SPECIAL_AMT: any = + item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? null_ : Number(item.SPECIAL_AMT); + profileSalary.amountSpecial = SPECIAL_AMT; profileSalary.profileEmployeeId = _item.id; profileSalary.refCommandNo = item.MP_COMMAND_NUM; profileSalary.posNo = item.POS_NUM_NAME + item.POS_NUM_CODE; - // profileSalary.position = item.FLAG_TO_NAME; profileSalary.position = item.WORK_LINE_NAME; profileSalary.positionPathSide = item.SPECIALIST_NAME; profileSalary.positionExecutive = item.ADMIN_NAME; profileSalary.templateDoc = item.REMARK; + profileSalary.refCommandDate = + item.MP_COMMAND_DATE == "" + ? null_ + : new Date(item.MP_COMMAND_DATE.replace(" +0700 +07:00", "")); + profileSalary.refCommandCode = item.FLAG_TO_NAME_CODE; + profileSalary.refCommandName = item.FLAG_TO_NAME; + profileSalary.orgRoot = item.DEPARTMENT_NAME; + profileSalary.orgChild1 = item.DIVISION_NAME; + profileSalary.orgChild2 = item.SECTION_NAME; + profileSalary.orgChild3 = item.JOB_NAME; + profileSalary.mpCee = item.MP_CEE; const ORDER_MOVE_POSITION: any = item.ORDER_MOVE_POSITION == null || item.ORDER_MOVE_POSITION == "" ? null_ @@ -424,10 +474,16 @@ export class ImportDataController extends Controller { profileSalary.createdFullName = request.user.name; profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateFullName = request.user.name; - profileSalary.createdAt = new Date(); - profileSalary.lastUpdatedAt = new Date(); + profileSalary.createdAt = + item.USER_CREATE == "" + ? null_ + : new Date(item.USER_CREATE.replace(" +0700 +07:00", "")); + profileSalary.lastUpdatedAt = + item.USER_UPDATE == "" + ? null_ + : new Date(item.USER_UPDATE.replace(" +0700 +07:00", "")); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); - await this.salaryRepository.save(profileSalary); + await this.salaryRepo.save(profileSalary); }), ); }), diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f74bbbef..c24bf083 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -99,7 +99,7 @@ export class ProfileController extends Controller { private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory); private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); - private salaryRepository = AppDataSource.getRepository(ProfileSalary); + private salaryRepo = AppDataSource.getRepository(ProfileSalary); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation); private provinceRepo = AppDataSource.getRepository(Province); private districtRepo = AppDataSource.getRepository(District); @@ -221,7 +221,7 @@ export class ProfileController extends Controller { let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; - const salary_raw = await this.salaryRepository.find({ + const salary_raw = await this.salaryRepo.find({ select: [ "date", "position", @@ -580,7 +580,7 @@ export class ProfileController extends Controller { field: "-", }, ]; - const salary_raw = await this.salaryRepository.find({ + const salary_raw = await this.salaryRepo.find({ select: [ "date", "position", @@ -1403,12 +1403,12 @@ export class ProfileController extends Controller { let condition: any = { orgRootId: posMaster.orgRootId || "", }; - // if (body.isDirector == true) { - condition = { - orgRootId: posMaster.orgRootId || "", - isDirector: true, - }; - // } + if (body.isDirector == true) { + condition = { + orgRootId: posMaster.orgRootId || "", + isDirector: true, + }; + } const [lists, total] = await AppDataSource.getRepository(viewDirectorActing) .createQueryBuilder("viewDirectorActing") .andWhere(condition) @@ -2034,6 +2034,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2056,6 +2058,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2098,10 +2107,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2111,14 +2120,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); } return new HttpSuccess(); } @@ -2138,6 +2155,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2173,6 +2192,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2209,10 +2235,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2222,15 +2248,23 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); await removeProfileInOrganize(profile.id, "OFFICER"); - await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); + await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2250,6 +2284,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2284,6 +2320,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2320,10 +2363,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2333,15 +2376,23 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); await removeProfileInOrganize(profile.id, "OFFICER"); - await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); + await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2361,6 +2412,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2395,6 +2448,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2431,10 +2491,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2444,31 +2504,23 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - // //เพิ่มวินัย - // const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), { - // date: body.date, - // profileId: body.profileId, - // refCommandNo: body.refCommandNo, - // createdUserId: req.user.sub, - // createdFullName: req.user.name, - // lastUpdateUserId: req.user.sub, - // lastUpdateFullName: req.user.name, - // createdAt: new Date(), - // lastUpdatedAt: new Date(), - // }); await removeProfileInOrganize(profile.id, "OFFICER"); - await Promise.all([ - this.profileRepo.save(_profile), - this.salaryRepository.save(profileSalary), - // this.profileDisciplineRepo.save(profileDiscipline) - ]); + await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2488,6 +2540,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2522,6 +2576,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2558,10 +2619,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2571,15 +2632,23 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); await removeProfileInOrganize(profile.id, "OFFICER"); - await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); + await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2599,6 +2668,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2632,6 +2703,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2668,10 +2746,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2681,15 +2759,23 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); await removeProfileInOrganize(profile.id, "OFFICER"); - await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); + await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2709,6 +2795,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2736,6 +2824,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2772,10 +2867,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2785,14 +2880,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2812,6 +2915,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2839,6 +2944,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2875,10 +2987,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2888,14 +3000,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -2915,6 +3035,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -2942,6 +3064,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -2979,10 +3108,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -2992,14 +3121,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -3019,6 +3156,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -3046,6 +3185,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3082,10 +3228,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -3095,14 +3241,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -3122,6 +3276,8 @@ export class ProfileController extends Controller { date: Date | null; refCommandNo: string | null; salaryRef: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }, ) { const profile = await this.profileRepo.findOne({ @@ -3149,6 +3305,13 @@ export class ProfileController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; const shortName = !profile.current_holders || profile.current_holders.length == 0 ? null @@ -3186,10 +3349,10 @@ export class ProfileController extends Controller { position: profile.position, positionType: profile.posType.posTypeName, positionLevel: profile.posLevel.posLevelName, - posNo: shortName ? shortName : "-", - positionLine: position?.positionField ?? "-", - positionPathSide: position?.positionArea ?? "-", - positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + posNo: shortName ? shortName : null, + positionLine: position?.positionField ?? null, + positionPathSide: position?.positionArea ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -3199,14 +3362,22 @@ export class ProfileController extends Controller { ? profile.profileSalary[0].order + 1 : 1 : null, + orgRoot: orgRootRef?.orgRootName ?? null, + orgChild1: orgChild1Ref?.orgChild1Name ?? null, + orgChild2: orgChild2Ref?.orgChild2Name ?? null, + orgChild3: orgChild3Ref?.orgChild3Name ?? null, + orgChild4: orgChild4Ref?.orgChild4Name ?? null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + refCommandDate: new Date(), + refCommandCode: body.refCommandCode, + refCommandName: body.refCommandName, }); - await Promise.all([this.salaryRepository.save(profileSalary)]); + await Promise.all([this.salaryRepo.save(profileSalary)]); return new HttpSuccess(); } @@ -8183,7 +8354,7 @@ export class ProfileController extends Controller { const _null: any = null; const profiles = await Promise.all( profile.map(async (_data) => { - const salary = await this.salaryRepository.findOne({ + const salary = await this.salaryRepo.findOne({ where: { profileId: _data.id, }, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index f108b8a6..7563ed27 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -91,7 +91,7 @@ export class ProfileEmployeeController extends Controller { private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); - private salaryRepository = AppDataSource.getRepository(ProfileSalary); + private salaryRepo = AppDataSource.getRepository(ProfileSalary); private orgRootRepository = AppDataSource.getRepository(OrgRoot); private child1Repository = AppDataSource.getRepository(OrgChild1); private child2Repository = AppDataSource.getRepository(OrgChild2); @@ -548,7 +548,7 @@ export class ProfileEmployeeController extends Controller { Field: "-", }, ]; - const salary_raw = await this.salaryRepository.find({ + const salary_raw = await this.salaryRepo.find({ select: [ "date", "position", diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 3896005e..23843010 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -90,7 +90,7 @@ export class ProfileEmployeeTempController extends Controller { private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather); private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); - private salaryRepository = AppDataSource.getRepository(ProfileSalary); + private salaryRepo = AppDataSource.getRepository(ProfileSalary); private orgRootRepository = AppDataSource.getRepository(OrgRoot); private child1Repository = AppDataSource.getRepository(OrgChild1); private child2Repository = AppDataSource.getRepository(OrgChild2); @@ -545,7 +545,7 @@ export class ProfileEmployeeTempController extends Controller { Field: "-", }, ]; - const salary_raw = await this.salaryRepository.find({ + const salary_raw = await this.salaryRepo.find({ select: [ "date", "position", diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 74daa7e0..b83552e3 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -119,10 +119,11 @@ export class ProfileSalaryController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; - const _null:any = null; + const _null: any = null; Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); @@ -131,11 +132,11 @@ export class ProfileSalaryController extends Controller { history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); - profile.amount = body?.amount??_null; - profile.positionSalaryAmount = body?.positionSalaryAmount??_null; - profile.mouthSalaryAmount = body.mouthSalaryAmount??_null; + profile.amount = body?.amount ?? _null; + profile.positionSalaryAmount = body?.positionSalaryAmount ?? _null; + profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null; await this.profileRepo.save(profile, { data: req }); - + return new HttpSuccess(); } @@ -164,6 +165,7 @@ export class ProfileSalaryController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; @@ -176,7 +178,7 @@ export class ProfileSalaryController extends Controller { history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); - let null_:any = null; + let null_: any = null; profile.amount = body.amount ?? null_; profile.amountSpecial = body.amountSpecial ?? null_; profile.positionSalaryAmount = body.positionSalaryAmount ?? null_; @@ -208,6 +210,7 @@ export class ProfileSalaryController extends Controller { history.lastUpdateFullName = req.user.name; history.createdUserId = req.user.sub; history.createdFullName = req.user.name; + record.refCommandDate = new Date(); history.createdAt = new Date(); history.lastUpdatedAt = new Date(); diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 0fb5bc9e..9cb74f29 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -130,6 +130,7 @@ export class ProfileSalaryEmployeeController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; @@ -137,17 +138,17 @@ export class ProfileSalaryEmployeeController extends Controller { Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - const _null:any = null; + const _null: any = null; await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); - profile.amount = body?.amount??_null; - profile.positionSalaryAmount = body?.positionSalaryAmount??_null; - profile.mouthSalaryAmount = body.mouthSalaryAmount??_null; + profile.amount = body?.amount ?? _null; + profile.positionSalaryAmount = body?.positionSalaryAmount ?? _null; + profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null; await this.profileRepo.save(profile, { data: req }); - + return new HttpSuccess(); } @@ -179,6 +180,7 @@ export class ProfileSalaryEmployeeController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; @@ -191,8 +193,8 @@ export class ProfileSalaryEmployeeController extends Controller { setLogDataDiff(req, { before, after: data }); history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); - - let null_:any = null; + + let null_: any = null; profile.amount = body.amount ?? null_; profile.amountSpecial = body.amountSpecial ?? null_; profile.positionSalaryAmount = body.positionSalaryAmount ?? null_; @@ -228,6 +230,7 @@ export class ProfileSalaryEmployeeController extends Controller { history.lastUpdateFullName = req.user.name; history.createdUserId = req.user.sub; history.createdFullName = req.user.name; + record.refCommandDate = new Date(); history.createdAt = new Date(); history.lastUpdatedAt = new Date(); diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index f4be602a..48d98ad3 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -122,6 +122,7 @@ export class ProfileSalaryEmployeeTempController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; @@ -158,6 +159,7 @@ export class ProfileSalaryEmployeeTempController extends Controller { record.lastUpdateUserId = req.user.sub; record.lastUpdateFullName = req.user.name; record.lastUpdatedAt = new Date(); + record.refCommandDate = new Date(); history.lastUpdateUserId = req.user.sub; history.lastUpdateFullName = req.user.name; history.createdUserId = req.user.sub; diff --git a/src/entities/CommandType.ts b/src/entities/CommandType.ts index 57261f8e..9ffe3162 100644 --- a/src/entities/CommandType.ts +++ b/src/entities/CommandType.ts @@ -28,6 +28,14 @@ export class CommandType extends EntityBase { }) code: string; + @Column({ + nullable: true, + comment: "รหัสประเภทของคำสั่งแต่งตั้ง", + length: 255, + default: null, + }) + refCommandCode: string; + @Column({ nullable: true, comment: "คำสั่งเรื่อง", diff --git a/src/entities/HR_POSITION_OFFICER.ts b/src/entities/HR_POSITION_OFFICER.ts index 02364867..2fbf0bef 100644 --- a/src/entities/HR_POSITION_OFFICER.ts +++ b/src/entities/HR_POSITION_OFFICER.ts @@ -94,4 +94,88 @@ export class HR_POSITION_OFFICER { default: null, }) ORDER_MOVE_POSITION: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MP_COMMAND_DATE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_TO_NAME_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + JOB_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SECTION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DIVISION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DEPARTMENT_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MP_CEE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SAL_POS_AMOUNT_1: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SAL_POS_AMOUNT_2: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPECIAL_AMT: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + USER_CREATE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + USER_UPDATE: string; } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index ad7217bd..edf937aa 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -127,6 +127,62 @@ export class ProfileSalary extends EntityBase { // }) // commandType: string; + @Column({ + nullable: true, + comment: "root name", + default: null, + }) + orgRoot: string; + + @Column({ + nullable: true, + comment: "child1 name", + default: null, + }) + orgChild1: string; + + @Column({ + nullable: true, + comment: "child2 name", + default: null, + }) + orgChild2: string; + + @Column({ + nullable: true, + comment: "child3 name", + default: null, + }) + orgChild3: string; + + @Column({ + nullable: true, + comment: "child4 name", + default: null, + }) + orgChild4: string; + + @Column({ + nullable: true, + comment: "ระดับ", + default: null, + }) + mpCee: string; + + @Column({ + nullable: true, + comment: "รหัสประเภทของคำสั่งแต่งตั้ง", + default: null, + }) + refCommandCode: string; + + @Column({ + nullable: true, + comment: "ชื่อประเภทคำสั่ง", + default: null, + }) + refCommandName: string; + @Column({ nullable: true, comment: "เลขที่คำสั่ง", @@ -135,6 +191,13 @@ export class ProfileSalary extends EntityBase { }) refCommandNo: string; + @Column({ + comment: "วันที่ออกคำสั่ง", + type: "datetime", + nullable: true, + }) + refCommandDate: Date; + @Column({ nullable: true, comment: "เอกสารอ้างอิง", @@ -207,6 +270,15 @@ export class CreateProfileSalary { // commandType?: string | null; templateDoc: string | null; isGovernment?: boolean | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; } export class CreateProfileSalaryEmployee { @@ -226,6 +298,15 @@ export class CreateProfileSalaryEmployee { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; } export class UpdateProfileSalaryEmployee { @@ -243,6 +324,15 @@ export class UpdateProfileSalaryEmployee { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; } export type UpdateProfileSalary = { @@ -260,4 +350,13 @@ export type UpdateProfileSalary = { positionLevel?: string | null; refCommandNo?: string | null; templateDoc?: string | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; }; diff --git a/src/entities/ProfileSalaryHistory.ts b/src/entities/ProfileSalaryHistory.ts index f419c222..d0ffc6d8 100644 --- a/src/entities/ProfileSalaryHistory.ts +++ b/src/entities/ProfileSalaryHistory.ts @@ -107,6 +107,70 @@ export class ProfileSalaryHistory extends EntityBase { }) mouthSalaryAmount: Double; + // @Column({ + // nullable: true, + // comment: "ประเภทคำสั่ง", + // type: "text", + // default: null, + // }) + // commandType: string; + + @Column({ + nullable: true, + comment: "root name", + default: null, + }) + orgRoot: string; + + @Column({ + nullable: true, + comment: "child1 name", + default: null, + }) + orgChild1: string; + + @Column({ + nullable: true, + comment: "child2 name", + default: null, + }) + orgChild2: string; + + @Column({ + nullable: true, + comment: "child3 name", + default: null, + }) + orgChild3: string; + + @Column({ + nullable: true, + comment: "child4 name", + default: null, + }) + orgChild4: string; + + @Column({ + nullable: true, + comment: "ระดับ", + default: null, + }) + mpCee: string; + + @Column({ + nullable: true, + comment: "รหัสประเภทของคำสั่งแต่งตั้ง", + default: null, + }) + refCommandCode: string; + + @Column({ + nullable: true, + comment: "ชื่อประเภทคำสั่ง", + default: null, + }) + refCommandName: string; + @Column({ nullable: true, comment: "เลขที่คำสั่ง", @@ -115,6 +179,13 @@ export class ProfileSalaryHistory extends EntityBase { }) refCommandNo: string; + @Column({ + comment: "วันที่ออกคำสั่ง", + type: "datetime", + nullable: true, + }) + refCommandDate: Date; + @Column({ nullable: true, comment: "เอกสารอ้างอิง", @@ -169,6 +240,15 @@ export class CreateProfileSalaryHistory { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; } export class UpdateProfileSalaryHistory { @@ -186,4 +266,13 @@ export class UpdateProfileSalaryHistory { positionLevel?: string | null; refCommandNo?: string | null; templateDoc?: string | null; + + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; } diff --git a/src/interfaces/functionMain.ts b/src/interfaces/functionMain.ts index 25f6a1bf..7c6fef4c 100644 --- a/src/interfaces/functionMain.ts +++ b/src/interfaces/functionMain.ts @@ -34,6 +34,7 @@ class FunctionMain { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + refCommandDate: new Date(), createdAt: new Date(), lastUpdatedAt: new Date(), }; diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 551a38f8..1035e842 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -24,10 +24,10 @@ export async function init() { const channel = await connection.createChannel(); //----> (1.4) create Channel console.log(channel ? "[AMQ] Create channel success" : "[AMQ] Create channel failed"); - + channel.assertQueue(queue, { durable: true }), //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ) - channel.assertQueue(queue_org, { durable: true }), - channel.prefetch(1) + channel.assertQueue(queue_org, { durable: true }), + channel.prefetch(1); sendToQueue = (payload: any, persistent = true) => { //----> (2) sendQueue To RabbitMQ and set persistent (if "true" redo the failed queue when server run again) @@ -42,7 +42,7 @@ export async function init() { console.log("[AMQ] Listening for message..."); createConsumer(queue, channel, handler), //----> (3) Process Consumer - createConsumer(queue_org, channel, handler_org) + createConsumer(queue_org, channel, handler_org); // createConsumer(queue2, channel, handler2); } @@ -82,7 +82,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise { const path = commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); return await new CallAPI() - + .PostData( { headers: { authorization: token }, @@ -102,6 +102,8 @@ async function handler(msg: amqp.ConsumeMessage): Promise { amountSpecial: x.amountSpecial, positionSalaryAmount: x.positionSalaryAmount, mouthSalaryAmount: x.mouthSalaryAmount, + refCommandCode: command.commandType.refCommandCode, + refCommandName: command.commandType.name, })), }, false,