add viewProfileEmp

This commit is contained in:
AdisakKanthawilang 2025-02-17 10:57:03 +07:00
parent db3c9583f6
commit ee71e985ab
3 changed files with 65 additions and 8 deletions

View file

@ -1174,12 +1174,12 @@ export class OrganizationUnauthorizeController extends Controller {
* @summary 5
*
*/
@Get("calculateEvaluation")
@Get("calculateEvaluation/{type}")
async calculateEvaluation(
// @Path() node: number,
@Path() type: string,
// @Path() nodeId: string,
) {
const conType = type.toUpperCase();
// let condition :any = {};
// switch (node) {
// case 0:
@ -1206,7 +1206,10 @@ export class OrganizationUnauthorizeController extends Controller {
// ...condition
// }
})
// if(conType == "EMPLOYEE"){
// const lists = await this.viewProfileEmployeeEvaluationRepo.find({
// })
// }
const groupData: any = {};
const year = new Date().getFullYear();
const years = [year, year - 1, year - 2, year - 3, year - 4];

View file

@ -83,7 +83,7 @@ export class ReportController extends Controller {
.andWhere(rootId?'posMaster.orgRootId = :rootId': "1=1", { rootId: rootId })
.andWhere('posMaster.current_holderId Is Not Null')
.andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD }) //ตอนนี้ where ที่วันที่บรรจุ (รอ prove) ว่าจะ where ที่ไหน
.andWhere(`
TIMESTAMPDIFF(YEAR, current_holder.birthDate, CURDATE()) >= :minAge
AND TIMESTAMPDIFF(YEAR, current_holder.birthDate, CURDATE()) <= :maxAge
@ -137,12 +137,11 @@ export class ReportController extends Controller {
...item ,
count: Extension.ToThaiNumber(item.count.toString()),
}));
return new HttpSuccess({
template: "registry-officer",
reportName: "xlsx-report",
data: {
year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
year: year?Extension.ToThaiNumber((year + 543).toString()):Extension.ToThaiNumber(((new Date()).getFullYear()+543).toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result
},
@ -248,7 +247,7 @@ export class ReportController extends Controller {
template: "registry-emp",
reportName: "xlsx-report",
data: {
year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
year: year?Extension.ToThaiNumber((year + 543).toString()):Extension.ToThaiNumber(((new Date()).getFullYear()+543).toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result
},

View file

@ -0,0 +1,55 @@
import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `SELECT
\`profileEmployeeId\`,
\`period\`,
\`year\`,
\`employeePosMaster\`.\`orgRootId\`,
\`employeePosMaster\`.\`orgChild1Id\`,
\`employeePosMaster\`.\`orgChild2Id\`,
\`employeePosMaster\`.\`orgChild3Id\`,
\`employeePosMaster\`.\`orgChild4Id\`,
COUNT(*) AS recordCount,
SUM(pointSum) AS totalPointSum,
SUM(pointSum) / COUNT(*) AS result
FROM \`profileAssessment\`
LEFT JOIN \`profileEmployee\` ON \`profileAssessment\`.\`profileEmployeeId\` = \`profileEmployee\`.\`id\`
LEFT JOIN \`employeePosMaster\` ON \`profileEmployee\`.\`id\` = \`employeePosMaster\`.\`current_holderId\`
LEFT JOIN \`orgRevision\` ON \`employeePosMaster\`.\`orgRevisionId\` = \`orgRevision\`.\`id\`
WHERE \`period\` IS NOT NULL
AND \`orgRevision\`.\`orgRevisionIsCurrent\` = TRUE
GROUP BY \`profileEmployeeId\`, \`period\`, \`year\`,
\`employeePosMaster\`.\`orgRootId\`,
\`employeePosMaster\`.\`orgChild1Id\`,
\`employeePosMaster\`.\`orgChild2Id\`,
\`employeePosMaster\`.\`orgChild3Id\`,
\`employeePosMaster\`.\`orgChild4Id\`
ORDER BY \`year\` DESC, \`period\` ASC;
`,
})
export class viewProfileEmployeeEvaluation {
@ViewColumn()
profileEmployeeId: string;
@ViewColumn()
period: string;
@ViewColumn()
year: number;
@ViewColumn()
orgRootId: string;
@ViewColumn()
orgChild1Id: string;
@ViewColumn()
orgChild2Id: string;
@ViewColumn()
orgChild3Id: string;
@ViewColumn()
orgChild4Id: string;
@ViewColumn()
recordCount: number;
@ViewColumn()
totalPointSum: number;
@ViewColumn()
result: number;
}