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.leaveDate = _null;
profile.leaveType = _null;
profile.leaveReason = _null;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date();

View file

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

View file

@ -42,16 +42,55 @@ import { ViewColumn, ViewEntity } from "typeorm";
WHERE orgRevision.orgRevisionIsCurrent IS TRUE
AND orgRevision.orgRevisionIsDraft IS FALSE
),
Education AS (
SELECT
ed.degree,
ed.profileEmployeeId,
ed.level,
ROW_NUMBER() OVER (PARTITION BY ed.profileEmployeeId ORDER BY ed.level DESC) AS ed_number
FROM profileEducation ed
WHERE ed.isUse IS TRUE
ORDER BY ed.level DESC
),
Educations AS (
SELECT
eds.profileEmployeeId,
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.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 (
SELECT
vcto.Years,
@ -108,7 +147,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
p.dateRetire,
p.dateRetireLaw,
p.birthdate,
ed.degree,
eds.Educations,
edls.educationLevels,
degs.degrees,
fies.fields,
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
vcto.Years,
vcto.Months,
@ -120,7 +162,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
LEFT JOIN employeePosLevel posLevel ON p.posLevelId = posLevel.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 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 PositionLevelDate vctlo ON p.id = vctlo.profileEmployeeId
`,
@ -242,4 +287,13 @@ export class viewRegistryEmployee {
@ViewColumn()
levelDays: number;
@ViewColumn()
Educations: object;
@ViewColumn()
educationLevels: string;
@ViewColumn()
fields: string;
}

View file

@ -6,6 +6,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
SELECT
posExecutive.posExecutiveName,
pn.posMasterId,
pn.positionArea,
ROW_NUMBER() OVER (PARTITION BY pn.posMasterId) AS pn_number
FROM position pn
LEFT JOIN posExecutive ON pn.posExecutiveId = posExecutive.id
@ -13,6 +14,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
),
PosMaster AS (
SELECT
pn.positionArea,
pm.current_holderId,
pm.posMasterNo,
pm.orgRootId,
@ -46,15 +48,56 @@ import { ViewColumn, ViewEntity } from "typeorm";
orgRevision.orgRevisionIsCurrent IS TRUE
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
ed.degree,
ed.profileId,
ed.level,
ROW_NUMBER() OVER (PARTITION BY ed.profileId ORDER BY ed.level DESC) AS ed_number
FROM profileEducation ed
WHERE ed.isUse IS TRUE
ORDER BY ed.level DESC
edls.profileId,
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.profileId
ORDER BY edls.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 (
SELECT
@ -103,6 +146,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
END AS org,
pm.searchShortName,
pm.posExecutiveName,
pm.positionArea,
p.position,
posType.posTypeName,
posLevel.posLevelName,
@ -112,7 +156,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
p.dateRetire,
p.dateRetireLaw,
p.birthdate,
ed.degree,
eds.Educations,
edls.educationLevels,
degs.degrees,
fies.fields,
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
vcto.Years,
vcto.Months,
@ -124,7 +171,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
LEFT JOIN posLevel ON p.posLevelId = posLevel.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 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 PositionLevelDate vctlo ON p.id = vctlo.profileId
`,
@ -249,4 +299,16 @@ export class viewRegistryOfficer {
@ViewColumn()
levelDays: number;
@ViewColumn()
positionArea: string;
@ViewColumn()
Educations: object;
@ViewColumn()
educationLevels: string;
@ViewColumn()
fields: string;
}