Compare commits

...

4 commits

Author SHA1 Message Date
harid
57dc171997 ปัดเศษจำนวนวันขึ้น
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
2026-04-10 17:55:29 +07:00
harid
a07d436db8 fix ข้อมูลผู้พ้นจากราชการก่อนปี 2568 ระบบไม่เก็บ logs #2383
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
2026-04-10 16:00:12 +07:00
harid
2864bea92f fix Noti แจ้งเตือนผิด #2417
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m9s
2026-04-09 17:32:03 +07:00
harid
6a1ca6b867 fix Noti แจ้งเตือนผิด #2417
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
2026-04-09 17:20:24 +07:00
8 changed files with 39 additions and 19 deletions

View file

@ -321,6 +321,7 @@ export class DevelopmentRequestController extends Controller {
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
id: true,
isDeputy: true
},
where: {
@ -369,7 +370,8 @@ export class DevelopmentRequestController extends Controller {
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
isDeputy: orgRoot?.isDeputy ?? false,
orgRootId: orgRoot?.id ?? null
})
.catch((error) => {
console.error("Error calling API:", error);

View file

@ -8966,13 +8966,13 @@ export class ProfileController extends Controller {
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
// "profileSalary",
"profileEducations",
],
order: {
profileSalary: {
order: "DESC",
},
// profileSalary: {
// order: "DESC",
// },
profileEducations: {
level: "ASC",
},

View file

@ -335,6 +335,7 @@ export class ProfileEditController extends Controller {
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
id: true,
isDeputy: true
},
where: {
@ -363,7 +364,8 @@ export class ProfileEditController extends Controller {
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
isDeputy: orgRoot?.isDeputy ?? false,
orgRootId: orgRoot?.id ?? null
})
.catch((error) => {
console.error("Error calling API:", error);

View file

@ -336,6 +336,7 @@ export class ProfileEditEmployeeController extends Controller {
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
id: true,
isDeputy: true
},
where: {
@ -363,7 +364,8 @@ export class ProfileEditEmployeeController extends Controller {
posLevelName: "EMP",
posTypeName: "EMP",
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
isDeputy: orgRoot?.isDeputy ?? false,
orgRootId: orgRoot?.id ?? null
})
.catch((error) => {
console.error("Error calling API:", error);

View file

@ -605,7 +605,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -644,7 +644,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -678,7 +678,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -742,7 +742,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -785,7 +785,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -822,7 +822,7 @@ export class ProfileSalaryController extends Controller {
// Recalculate year, month, and day
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},

View file

@ -177,7 +177,7 @@ export class ProfileSalaryEmployeeController extends Controller {
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -213,7 +213,7 @@ export class ProfileSalaryEmployeeController extends Controller {
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -268,7 +268,7 @@ export class ProfileSalaryEmployeeController extends Controller {
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},
@ -304,7 +304,7 @@ export class ProfileSalaryEmployeeController extends Controller {
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.floor(existing.days % 30.4375);
existing.day = Math.ceil(existing.days % 30.4375);
return acc;
},

View file

@ -54,6 +54,7 @@ export class WorkflowController extends Controller {
posTypeName: string;
fullName?: string | null;
isDeputy?: boolean | null;
orgRootId?: string | null;
},
) {
// ขั้นที่ 1: ทำการค้นหา profile และ metaWorkflow แบบ parallel
@ -203,9 +204,10 @@ export class WorkflowController extends Controller {
posMasterAssigns: { assignId: body.sysName },
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
current_holderId: Not(IsNull()), // เพิ่มเงื่อนไขนี้เพื่อกรองเฉพาะที่มี current_holder
...(body.orgRootId && { orgRootId: body.orgRootId }), // กรองเฉพาะที่อยู่ในสำนักเดียวกัน (ถ้าส่งมา)
},
relations: ["orgChild1"],
select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น
// select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น
});
// สร้าง StateOperatorUsers สำหรับ officers

View file

@ -56,6 +56,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
if (req.url.startsWith("/api/v1/org/profile/")) system = "registry";
if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry";
if (req.url.startsWith("/api/v1/org/profile-temp/")) system = "registry";
if (req.url.startsWith("/api/v1/org/ex/")) system = "retirement";
if (req.url.startsWith("/api/v1/org/commandType/admin")) system = "admin";
if (req.url.startsWith("/api/v1/org/commandSys/")) system = "admin";
@ -79,6 +80,17 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
// Get rootId from token
const rootId = req.app.locals.logData?.orgRootDnaId;
let _msg = data?.message;
if (!_msg) {
if (res.statusCode >= 500) {
_msg = "ไม่สำเร็จ";
} else if (res.statusCode >= 400) {
_msg = "พบข้อผิดพลาด";
} else if (res.statusCode >= 200) {
_msg = "สำเร็จ";
}
}
if (level === 1 && res.statusCode < 500) return;
if (level === 2 && res.statusCode < 400) return;
if (level === 3 && res.statusCode < 200) return;
@ -94,7 +106,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
method: req.method,
endpoint: req.url,
responseCode: String(res.statusCode === 304 ? 200 : res.statusCode),
responseDescription: data?.message,
responseDescription: _msg,
input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined,
output: level === 4 ? JSON.stringify(data, null, 2) : undefined,
...req.app.locals.logData,