This commit is contained in:
Bright 2025-03-07 18:09:29 +07:00
parent 09eab4d6a1
commit 2b0865ea9f
4 changed files with 146 additions and 22 deletions

View file

@ -4498,6 +4498,7 @@ export class CommandController extends Controller {
profile.leaveRemark = _null; profile.leaveRemark = _null;
profile.leaveDate = _null; profile.leaveDate = _null;
profile.leaveType = _null; profile.leaveType = _null;
profile.leaveReason = _null;
profile.lastUpdateUserId = req.user.sub; profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name; profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date(); profile.lastUpdatedAt = new Date();

View file

@ -161,6 +161,13 @@ export class ProfileEducation extends EntityBase {
}) })
isEducation: boolean; isEducation: boolean;
@Column({
nullable: true,
comment: "เป็นวุฒิศึกษาสูงสุด",
default: null,
})
isHigh: boolean;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ใช้ประวัติการศึกษา", comment: "ใช้ประวัติการศึกษา",

View file

@ -42,16 +42,55 @@ import { ViewColumn, ViewEntity } from "typeorm";
WHERE orgRevision.orgRevisionIsCurrent IS TRUE WHERE orgRevision.orgRevisionIsCurrent IS TRUE
AND orgRevision.orgRevisionIsDraft IS FALSE AND orgRevision.orgRevisionIsDraft IS FALSE
), ),
Education AS ( Educations AS (
SELECT SELECT
ed.degree, eds.profileEmployeeId,
ed.profileEmployeeId, JSON_ARRAYAGG(
ed.level, JSON_OBJECT(
ROW_NUMBER() OVER (PARTITION BY ed.profileEmployeeId ORDER BY ed.level DESC) AS ed_number 'degree', eds.degree,
FROM profileEducation ed 'field', eds.field,
WHERE ed.isUse IS TRUE 'educationLevel', eds.educationLevel,
ORDER BY ed.level DESC 'isEducation', eds.isEducation,
), 'isHigh', eds.isHigh
)
) AS Educations
FROM (
SELECT DISTINCT
eds.degree,
eds.field,
eds.educationLevel,
eds.isEducation,
eds.isHigh,
eds.profileEmployeeId
FROM profileEducation eds
) AS eds
GROUP BY eds.profileEmployeeId
),
EducationLevels AS (
SELECT
edls.profileEmployeeId,
GROUP_CONCAT(DISTINCT edls.educationLevel ORDER BY edls.educationLevel SEPARATOR ', ') AS educationLevels
FROM profileEducation edls
WHERE edls.educationLevel IS NOT NULL AND edls.educationLevel != ''
GROUP BY edls.profileEmployeeId
ORDER BY edls.level DESC
),
Degrees AS (
SELECT
degs.profileEmployeeId,
GROUP_CONCAT(DISTINCT degs.degree ORDER BY degs.degree SEPARATOR ', ') AS degrees
FROM profileEducation degs
WHERE degs.degree IS NOT NULL AND degs.degree != ''
GROUP BY degs.profileEmployeeId
),
Fields AS (
SELECT
fies.profileEmployeeId,
GROUP_CONCAT(DISTINCT fies.field ORDER BY fies.field SEPARATOR ', ') AS fields
FROM profileEducation fies
WHERE fies.field IS NOT NULL AND fies.field != ''
GROUP BY fies.profileEmployeeId
),
PositionDate AS ( PositionDate AS (
SELECT SELECT
vcto.Years, vcto.Years,
@ -108,7 +147,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
p.dateRetire, p.dateRetire,
p.dateRetireLaw, p.dateRetireLaw,
p.birthdate, p.birthdate,
ed.degree, eds.Educations,
edls.educationLevels,
degs.degrees,
fies.fields,
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age, TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
vcto.Years, vcto.Years,
vcto.Months, vcto.Months,
@ -120,7 +162,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
LEFT JOIN employeePosLevel posLevel ON p.posLevelId = posLevel.id LEFT JOIN employeePosLevel posLevel ON p.posLevelId = posLevel.id
LEFT JOIN employeePosType posType ON p.posTypeId = posType.id LEFT JOIN employeePosType posType ON p.posTypeId = posType.id
LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1 LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1
LEFT JOIN Education ed ON p.id = ed.profileEmployeeId AND ed.ed_number = 1 LEFT JOIN Educations eds ON p.id = eds.profileEmployeeId
LEFT JOIN EducationLevels edls ON p.id = edls.profileEmployeeId
LEFT JOIN Degrees degs ON p.id = degs.profileEmployeeId
LEFT JOIN Fields fies ON p.id = fies.profileEmployeeId
LEFT JOIN PositionDate vcto ON p.id = vcto.profileEmployeeId LEFT JOIN PositionDate vcto ON p.id = vcto.profileEmployeeId
LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileEmployeeId LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileEmployeeId
`, `,
@ -242,4 +287,13 @@ export class viewRegistryEmployee {
@ViewColumn() @ViewColumn()
levelDays: number; levelDays: number;
@ViewColumn()
Educations: object;
@ViewColumn()
educationLevels: string;
@ViewColumn()
fields: string;
} }

View file

@ -6,6 +6,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
SELECT SELECT
posExecutive.posExecutiveName, posExecutive.posExecutiveName,
pn.posMasterId, pn.posMasterId,
pn.positionArea,
ROW_NUMBER() OVER (PARTITION BY pn.posMasterId) AS pn_number ROW_NUMBER() OVER (PARTITION BY pn.posMasterId) AS pn_number
FROM position pn FROM position pn
LEFT JOIN posExecutive ON pn.posExecutiveId = posExecutive.id LEFT JOIN posExecutive ON pn.posExecutiveId = posExecutive.id
@ -13,6 +14,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
), ),
PosMaster AS ( PosMaster AS (
SELECT SELECT
pn.positionArea,
pm.current_holderId, pm.current_holderId,
pm.posMasterNo, pm.posMasterNo,
pm.orgRootId, pm.orgRootId,
@ -46,15 +48,56 @@ import { ViewColumn, ViewEntity } from "typeorm";
orgRevision.orgRevisionIsCurrent IS TRUE orgRevision.orgRevisionIsCurrent IS TRUE
AND orgRevision.orgRevisionIsDraft IS FALSE AND orgRevision.orgRevisionIsDraft IS FALSE
), ),
Education AS ( Educations AS (
SELECT
eds.profileId,
JSON_ARRAYAGG(
JSON_OBJECT(
'degree', eds.degree,
'field', eds.field,
'educationLevel', eds.educationLevel,
'isEducation', eds.isEducation,
'isHigh', eds.isHigh
)
) AS Educations
FROM (
SELECT DISTINCT
eds.degree,
eds.field,
eds.educationLevel,
eds.isEducation,
eds.isHigh,
eds.profileId
FROM profileEducation eds
) AS eds
GROUP BY eds.profileId
),
EducationLevels AS (
SELECT SELECT
ed.degree, edls.profileId,
ed.profileId, GROUP_CONCAT(DISTINCT edls.educationLevel ORDER BY edls.educationLevel SEPARATOR ', ') AS educationLevels
ed.level, FROM profileEducation edls
ROW_NUMBER() OVER (PARTITION BY ed.profileId ORDER BY ed.level DESC) AS ed_number WHERE edls.educationLevel IS NOT NULL AND edls.educationLevel != ''
FROM profileEducation ed GROUP BY edls.profileId
WHERE ed.isUse IS TRUE ORDER BY edls.level DESC
ORDER BY ed.level DESC ),
Degrees AS (
SELECT
degs.profileId,
GROUP_CONCAT(DISTINCT degs.degree ORDER BY degs.degree SEPARATOR ', ') AS degrees
FROM profileEducation degs
WHERE degs.degree IS NOT NULL AND degs.degree != ''
GROUP BY degs.profileId
ORDER BY degs.level DESC
),
Fields AS (
SELECT
fies.profileId,
GROUP_CONCAT(DISTINCT fies.field ORDER BY fies.field SEPARATOR ', ') AS fields
FROM profileEducation fies
WHERE fies.field IS NOT NULL AND fies.field != ''
GROUP BY fies.profileId
ORDER BY fies.level DESC
), ),
PositionDate AS ( PositionDate AS (
SELECT SELECT
@ -103,6 +146,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
END AS org, END AS org,
pm.searchShortName, pm.searchShortName,
pm.posExecutiveName, pm.posExecutiveName,
pm.positionArea,
p.position, p.position,
posType.posTypeName, posType.posTypeName,
posLevel.posLevelName, posLevel.posLevelName,
@ -112,7 +156,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
p.dateRetire, p.dateRetire,
p.dateRetireLaw, p.dateRetireLaw,
p.birthdate, p.birthdate,
ed.degree, eds.Educations,
edls.educationLevels,
degs.degrees,
fies.fields,
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age, TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
vcto.Years, vcto.Years,
vcto.Months, vcto.Months,
@ -124,7 +171,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
LEFT JOIN posLevel ON p.posLevelId = posLevel.id LEFT JOIN posLevel ON p.posLevelId = posLevel.id
LEFT JOIN posType ON p.posTypeId = posType.id LEFT JOIN posType ON p.posTypeId = posType.id
LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1 LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1
LEFT JOIN Education ed ON p.id = ed.profileId AND ed.ed_number = 1 LEFT JOIN Educations eds ON p.id = eds.profileId
LEFT JOIN EducationLevels edls ON p.id = edls.profileId
LEFT JOIN Degrees degs ON p.id = degs.profileId
LEFT JOIN Fields fies ON p.id = fies.profileId
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId LEFT JOIN PositionDate vcto ON p.id = vcto.profileId
LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileId LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileId
`, `,
@ -249,4 +299,16 @@ export class viewRegistryOfficer {
@ViewColumn() @ViewColumn()
levelDays: number; levelDays: number;
@ViewColumn()
positionArea: string;
@ViewColumn()
Educations: object;
@ViewColumn()
educationLevels: string;
@ViewColumn()
fields: string;
} }