add feild viewProfileEva

This commit is contained in:
AdisakKanthawilang 2025-02-07 18:04:12 +07:00
parent f01ed53d47
commit edd21d8777
2 changed files with 64 additions and 38 deletions

View file

@ -2,12 +2,16 @@ import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `SELECT
\`profileId\`, \`period\`, \`year\`, COUNT(*) AS recordCount, SUM(pointSum) AS totalPointSum, SUM(pointSum) / COUNT(*) AS result
FROM \`profileAssessment\`
\`profileId\`,\`period\`,\`year\`,\`posMaster\`.\`orgRootId\`,\`posMaster\`.\`orgChild1Id\`,\`posMaster\`.\`orgChild2Id\`,\`posMaster\`.\`orgChild3Id\`,\`posMaster\`.\`orgChild4Id\`, COUNT(*) AS recordCount, SUM(pointSum) AS totalPointSum, SUM(pointSum) / COUNT(*) AS result
FROM\`profileAssessment\`
LEFT JOIN \`profile\` ON \`profileAssessment\`.\`profileId\` = \`profile\`.\`id\`
LEFT JOIN \`posMaster\` ON \`profile\`.\`id\` = \`posMaster\`.\`current_holderId\`
LEFT JOIN \`orgRevision\` ON \`posMaster\`.\`orgRevisionId\` = \`orgRevision\`.\`id\`
WHERE \`period\` Is not null
GROUP BY \`profileId\`, \`period\`, \`year\`
ORDER BY \`year\` desc , \`period\` asc
`,
AND \`orgRevision\`.\`orgRevisionIsCurrent\` = true
GROUP BY\`profileId\`,\`period\`,\`year\`,\`orgRootId\`,\`orgChild1Id\`,\`orgChild2Id\`,\`orgChild3Id\`,\`orgChild4Id\`
ORDER BY\`year\` desc ,\`period\` asc
`,
})
export class viewProfileEvaluation {
@ViewColumn()
@ -17,6 +21,16 @@ export class viewProfileEvaluation {
@ViewColumn()
year: number;
@ViewColumn()
orgRootId: string;
@ViewColumn()
orgChild1Id: string;
@ViewColumn()
orgChild2Id: string;
@ViewColumn()
orgChild3Id: string;
@ViewColumn()
orgChild4Id: string;
@ViewColumn()
recordCount: number;
@ViewColumn()
totalPointSum: number;