diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 8c7a747b..48768a79 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3397,6 +3397,10 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } const returnWork = await checkReturnCommandType(String(item.commandId)); const dest_item = await this.salaryRepo.findOne({ where: { profileId: item.profileId }, @@ -3425,7 +3429,6 @@ export class CommandController extends Controller { history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); } - const _null: any = null; profile.isLeave = item.isLeave; profile.leaveReason = item.leaveReason ?? _null; @@ -3447,7 +3450,7 @@ export class CommandController extends Controller { } } profile.leaveCommandId = item.commandId ?? _null; - profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; profile.leaveRemark = clearProfile.leaveRemark ?? _null; profile.leaveDate = item.commandDateAffect ?? _null; profile.leaveType = clearProfile.LeaveType ?? _null; @@ -3683,7 +3686,10 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } const dest_item = await this.salaryRepo.findOne({ where: { profileEmployeeId: item.profileId }, order: { order: "DESC" }, @@ -3737,7 +3743,7 @@ export class CommandController extends Controller { } } profile.leaveCommandId = item.commandId ?? _null; - profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; profile.leaveRemark = clearProfile.leaveRemark ?? _null; profile.leaveDate = item.commandDateAffect ?? _null; profile.leaveType = clearProfile.LeaveType ?? _null; @@ -3845,7 +3851,10 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } - + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } const dest_item = await this.salaryRepo.findOne({ where: { profileId: item.profileId }, order: { order: "DESC" }, @@ -3879,7 +3888,7 @@ export class CommandController extends Controller { } profile.isLeave = item.isLeave; profile.leaveCommandId = item.commandId ?? _null; - profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; profile.leaveRemark = clearProfile.leaveRemark ?? _null; profile.leaveDate = item.commandDateAffect ?? _null; profile.leaveType = clearProfile.LeaveType ?? _null; @@ -4148,6 +4157,10 @@ export class CommandController extends Controller { } await Promise.all( body.data.map(async (item) => { + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") { const profile = await this.profileRepository.findOne({ relations: [ @@ -4314,7 +4327,7 @@ export class CommandController extends Controller { if (exceptClear.status) { _profile.leaveReason = item.leaveReason ?? _null; _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = exceptClear.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = exceptClear.LeaveType ?? _null; @@ -4333,7 +4346,7 @@ export class CommandController extends Controller { } } _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = clearProfile.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = clearProfile.LeaveType ?? _null; @@ -4513,7 +4526,7 @@ export class CommandController extends Controller { if (exceptClear.status) { _profile.leaveReason = item.leaveReason ?? _null; _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = exceptClear.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = exceptClear.LeaveType ?? _null; @@ -4532,7 +4545,7 @@ export class CommandController extends Controller { } } _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = clearProfile.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = clearProfile.LeaveType ?? _null; @@ -4654,6 +4667,10 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } // const orgRevision = await this.orgRevisionRepo.findOne({ // where: { // orgRevisionIsCurrent: true, @@ -4798,7 +4815,7 @@ export class CommandController extends Controller { if (exceptClear.status) { _profile.leaveReason = item.leaveReason ?? _null; _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = exceptClear.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = exceptClear.LeaveType ?? _null; @@ -4817,7 +4834,7 @@ export class CommandController extends Controller { } } _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = clearProfile.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = clearProfile.LeaveType ?? _null; @@ -5132,6 +5149,10 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } + let _commandYear = item.commandYear; + if (item.commandYear) { + _commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear+543 + } const _profile = await this.profileRepository.findOne({ where: { id: item.profileId }, relations: ["roleKeycloaks"], @@ -5247,7 +5268,7 @@ export class CommandController extends Controller { } } _profile.leaveCommandId = item.commandId ?? _null; - _profile.leaveCommandNo = `${item.commandNo}/${item.commandYear}`; + _profile.leaveCommandNo = `${item.commandNo}/${_commandYear}`; _profile.leaveRemark = clearProfile.leaveRemark ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = clearProfile.LeaveType ?? _null; diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 7a0afa53..23adf4ef 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -149,9 +149,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise { .map((x) => ({ refId: x.refId, commandNo: command.commandNo, - commandYear: command.commandYear > 2500 - ? command.commandYear - : command.commandYear + 543, + commandYear: command.commandYear, commandId: command.id, remark: command.positionDetail, amount: x.amount,