2025-04-02 10:01:00 +07:00
|
|
|
import { ViewColumn, ViewEntity } from "typeorm";
|
|
|
|
|
|
|
|
|
|
@ViewEntity({
|
|
|
|
|
expression: `SELECT
|
|
|
|
|
posMaster.id,
|
|
|
|
|
posMaster.posMasterNoPrefix,
|
|
|
|
|
posMaster.posMasterNo,
|
|
|
|
|
posMaster.posMasterNoSuffix,
|
2025-04-03 16:53:23 +07:00
|
|
|
posMaster.orgRevisionId,
|
2025-04-02 10:01:00 +07:00
|
|
|
posMaster.orgRootId,
|
|
|
|
|
posMaster.orgChild1Id,
|
|
|
|
|
posMaster.orgChild2Id,
|
|
|
|
|
posMaster.orgChild3Id,
|
|
|
|
|
posMaster.orgChild4Id,
|
|
|
|
|
posMaster.current_holderId,
|
|
|
|
|
profile.id as profileId,
|
|
|
|
|
profile.prefix,
|
|
|
|
|
profile.firstName,
|
|
|
|
|
profile.lastName,
|
|
|
|
|
profile.citizenId,
|
|
|
|
|
profile.position,
|
|
|
|
|
profile.amount,
|
|
|
|
|
profile.dateRetire,
|
|
|
|
|
profile.birthDate,
|
|
|
|
|
orgRoot.id as rootId,
|
|
|
|
|
orgRoot.orgRootShortName,
|
2025-04-11 11:53:51 +07:00
|
|
|
orgRoot.orgRootOrder,
|
2025-04-03 16:53:23 +07:00
|
|
|
orgRoot.orgRootName,
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild1.id as child1Id,
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild1.orgChild1ShortName,
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild1.orgChild1Order,
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild1.orgChild1Name,
|
|
|
|
|
orgChild2.id as child2Id,
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild2.orgChild2ShortName,
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild2.orgChild2Order,
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild2.orgChild2Name,
|
|
|
|
|
orgChild3.id as child3Id,
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild3.orgChild3ShortName,
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild3.orgChild3Order,
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild3.orgChild3Name,
|
|
|
|
|
orgChild4.id as child4Id,
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild4.orgChild4ShortName,
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild4.orgChild4Order,
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild4.orgChild4Name,
|
|
|
|
|
position.id as positionId,
|
|
|
|
|
position.positionIsSelected,
|
2025-04-02 14:00:54 +07:00
|
|
|
position.posExecutiveId as positionPosExecutiveId,
|
2025-04-02 10:01:00 +07:00
|
|
|
position.isSpecial,
|
|
|
|
|
posExecutive.id as posExecutiveId,
|
|
|
|
|
posExecutive.posExecutiveName,
|
|
|
|
|
profileDiscipline.id as profileDisciplineId,
|
|
|
|
|
profileDiscipline.date as disCriplineDate,
|
|
|
|
|
profileLeave.id as profileLeaveId,
|
|
|
|
|
profileAssessment.id as profileAssessmentId,
|
|
|
|
|
profileAssessment.pointSum,
|
|
|
|
|
posLevel.id as posLevelId,
|
|
|
|
|
posLevel.posLevelName,
|
|
|
|
|
posType.id as posTypeId,
|
|
|
|
|
posType.posTypeName
|
|
|
|
|
FROM
|
|
|
|
|
posMaster
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
profile ON posMaster.current_holderId = profile.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
orgRoot ON posMaster.orgRootId = orgRoot.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
orgChild1 ON posMaster.orgChild1Id = orgChild1.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
orgChild2 ON posMaster.orgChild2Id = orgChild2.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
orgChild3 ON posMaster.orgChild3Id = orgChild3.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
orgChild4 ON posMaster.orgChild4Id = orgChild4.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
position ON posMaster.id = position.posMasterId
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
posExecutive ON position.posExecutiveId = posExecutive.id
|
2025-05-01 13:14:38 +07:00
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT *
|
|
|
|
|
FROM profileDiscipline pd1
|
|
|
|
|
WHERE pd1.date = (
|
|
|
|
|
SELECT MAX(pd2.date)
|
|
|
|
|
FROM profileDiscipline pd2
|
|
|
|
|
WHERE pd2.profileId = pd1.profileId
|
|
|
|
|
)
|
|
|
|
|
) AS profileDiscipline ON profileDiscipline.profileId = profile.id
|
2025-04-02 10:01:00 +07:00
|
|
|
LEFT JOIN
|
|
|
|
|
profileLeave ON profileLeave.profileId = profile.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
profileAssessment ON profileAssessment.profileId = profile.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
posLevel ON profile.posLevelId = posLevel.id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
posType ON profile.posTypeId = posType.id
|
|
|
|
|
WHERE
|
|
|
|
|
posMaster.current_holderId IS NOT NULL
|
|
|
|
|
ORDER BY
|
|
|
|
|
profile.citizenId ASC
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export class viewPosMaster {
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
id: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posMasterNoPrefix: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posMasterNo: number;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posMasterNoSuffix: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgRevisionId: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
orgRootId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
orgChild1Id: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
orgChild2Id: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
orgChild3Id: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
orgChild4Id: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
current_holderId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
profileId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
prefix: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
firstName: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
lastName: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
citizenId: number;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
position: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
amount: number;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
dateRetire: Date;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
birthDate: Date;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
rootId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
orgRootShortName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-11 11:53:51 +07:00
|
|
|
orgRootOrder: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgRootName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
child1Id: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild1ShortName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild1Order: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild1Name: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
child2Id: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild2ShortName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild2Order: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild2Name: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
child3Id: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild3ShortName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild3Order: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild3Name: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
child4Id: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
orgChild4ShortName: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-11 11:53:51 +07:00
|
|
|
orgChild4Order: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 10:01:00 +07:00
|
|
|
orgChild4Name: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
positionId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
positionIsSelected: boolean;
|
|
|
|
|
@ViewColumn()
|
2025-04-02 14:00:54 +07:00
|
|
|
positionPosExecutiveId: string;
|
2025-04-02 10:01:00 +07:00
|
|
|
@ViewColumn()
|
|
|
|
|
isSpecial: boolean;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
posExecutiveId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posExecutiveName: string;
|
2025-04-02 10:01:00 +07:00
|
|
|
@ViewColumn()
|
|
|
|
|
profileDisciplineId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
disCriplineDate: Date;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
profileLeaveId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
profileAssessmentId: string;
|
|
|
|
|
@ViewColumn()
|
2025-04-03 16:53:23 +07:00
|
|
|
pointSum: number;
|
2025-04-02 10:01:00 +07:00
|
|
|
@ViewColumn()
|
|
|
|
|
posLevelId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posLevelName: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posTypeId: string;
|
|
|
|
|
@ViewColumn()
|
|
|
|
|
posTypeName: string;
|
|
|
|
|
}
|