From c5675359b3afda4c220a4992d7eb2e9b592bd9c8 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 29 Jun 2026 14:30:34 +0700 Subject: [PATCH] Linear Flow Probation #224 --- src/controllers/ReportController.ts | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ead19a5..ed36f8f 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1204,6 +1204,8 @@ export class ReportController extends Controller { }, ) { try { + // old cicle flow + /* await new CallAPI().PostData(request, "/org/command/excexute/salary-probation", { data: body.refIds.map((v) => ({ profileId: v.refId, @@ -1236,6 +1238,32 @@ export class ReportController extends Controller { ); return new HttpSuccess(); + */ + // 1) Linear Flow: อัปเดต probation_status = 9 (ผ่านทดลองงาน) — bulk update แทน N+1 save + await this.personalRepository.update( + { + probation_status: 8, + personal_id: In(body.refIds.map((x) => x.refId)), + }, + { probation_status: 9 }, + ); + + // 2) return data ให้ org ทำงานต่อ + return body.refIds.map((v) => ({ + profileId: v.refId, + commandId: v.commandId, + amount: v.amount, + amountSpecial: v.amountSpecial, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + commandNo: v.commandNo, + commandYear: v.commandYear, + commandDateAffect: v.commandDateAffect, + commandDateSign: v.commandDateSign, + commandCode: v.commandCode, + commandName: v.commandName, + remark: v.remark, + })); } catch (error: any) { if (error instanceof HttpError) { throw error; @@ -1321,6 +1349,8 @@ export class ReportController extends Controller { }, ) { try { + // old cicle flow + /* await new CallAPI().PostData(request, "/org/command/excexute/salary-probation-leave", { data: body.refIds.map((v) => ({ profileId: v.refId, @@ -1354,6 +1384,33 @@ export class ReportController extends Controller { ); return new HttpSuccess(); + */ + // 1) Linear Flow: อัปเดต probation_status = 9 — bulk update แทน N+1 save + await this.personalRepository.update( + { + probation_status: 8, + personal_id: In(body.refIds.map((x) => x.refId)), + }, + { probation_status: 9 }, + ); + + // 2) return data ให้ org ทำงานต่อ + return body.refIds.map((v) => ({ + profileId: v.refId, + commandId: v.commandId, + amount: v.amount, + amountSpecial: v.amountSpecial, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + isGovernment: false, + commandNo: v.commandNo, + commandYear: v.commandYear, + commandDateAffect: v.commandDateAffect, + commandDateSign: v.commandDateSign, + commandCode: v.commandCode, + commandName: v.commandName, + remark: v.remark, + })); } catch (error: any) { if (error instanceof HttpError) { throw error; @@ -1453,6 +1510,7 @@ export class ReportController extends Controller { }), ); return new HttpSuccess(); + } catch (error: any) { if (error instanceof HttpError) { throw error;