add view
This commit is contained in:
parent
e785ece48d
commit
ef88894ea4
2 changed files with 78 additions and 2 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
import { Controller, Get, Post, Route, Tags, Body, Path, Response, Patch } from "tsoa";
|
import { Controller, Get, Post, Route, Tags, Body, Path, Response, Patch, Query } from "tsoa";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { Brackets, IsNull, Not } from "typeorm";
|
import { Brackets, In, IsNull, Not } from "typeorm";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { calculateRetireDate } from "../interfaces/utils";
|
import { calculateRetireDate } from "../interfaces/utils";
|
||||||
|
|
@ -12,6 +12,9 @@ import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
import { ProfileAssessment } from "../entities/ProfileAssessment";
|
||||||
|
import { log } from "console";
|
||||||
|
import { format } from "path";
|
||||||
|
|
||||||
@Route("api/v1/org/unauthorize")
|
@Route("api/v1/org/unauthorize")
|
||||||
@Tags("OrganizationUnauthorize")
|
@Tags("OrganizationUnauthorize")
|
||||||
|
|
@ -24,6 +27,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
||||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||||
|
private profileAssessmentRepo = AppDataSource.getRepository(ProfileAssessment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
||||||
|
|
@ -1161,6 +1165,53 @@ export class OrganizationUnauthorizeController extends Controller {
|
||||||
return new HttpSuccess("Email verified successfully.");
|
return new HttpSuccess("Email verified successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ผลการประเมิน 5 ปีย้อนหลังนับจากปีปัจจุบัน
|
||||||
|
*
|
||||||
|
* @summary ผลการประเมิน 5 ปีย้อนหลังนับจากปีปัจจุบัน
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("calculate-Eva/{profileId}")
|
||||||
|
async calculateEva(
|
||||||
|
@Path() profileId: string,
|
||||||
|
) {
|
||||||
|
|
||||||
|
// const list = await this.viewProfileEvaluation.findOne({
|
||||||
|
// where: {
|
||||||
|
// profileId: profileId,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const formattedData = list.map((item: any) => {
|
||||||
|
// const year = new Date().getFullYear();
|
||||||
|
// const result: any = {};
|
||||||
|
|
||||||
|
// for (let i = 1; i <= 5; i++) {
|
||||||
|
// const currentYear = year - (i - 1);
|
||||||
|
// const periodKey = `periodAPR${i}`;
|
||||||
|
// const resultKey = `resultAPR${i}`;
|
||||||
|
|
||||||
|
// result[`yearAPR${i}`] = item.year === currentYear ? item.year : "-";
|
||||||
|
// result[periodKey] = item.period ? item.period : "-";
|
||||||
|
// result[resultKey] = item.result ? item.result : "-";
|
||||||
|
|
||||||
|
// const octYear = year - (i - 1);
|
||||||
|
// const octPeriodKey = `periodOCT${i}`;
|
||||||
|
// const octResultKey = `resultOCT${i}`;
|
||||||
|
|
||||||
|
// result[`yearOCT${i}`] = item.year === octYear ? item.year : "-";
|
||||||
|
// result[octPeriodKey] = item.period ? item.period : "-";
|
||||||
|
// result[octResultKey] = item.result ? item.result : "-";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return result;
|
||||||
|
// });
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Patch("retirement")
|
// @Patch("retirement")
|
||||||
// public async updateStatusRetirement(
|
// public async updateStatusRetirement(
|
||||||
// @Body()
|
// @Body()
|
||||||
|
|
|
||||||
25
src/entities/view/viewProfileEvaluation.ts
Normal file
25
src/entities/view/viewProfileEvaluation.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
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\`
|
||||||
|
WHERE \`period\` Is not null
|
||||||
|
GROUP BY \`profileId\`, \`period\`, \`year\`
|
||||||
|
ORDER BY \`year\` desc , \`period\` asc
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class viewDirectorActing {
|
||||||
|
@ViewColumn()
|
||||||
|
profileId: string;
|
||||||
|
@ViewColumn()
|
||||||
|
period: string;
|
||||||
|
@ViewColumn()
|
||||||
|
year: number;
|
||||||
|
@ViewColumn()
|
||||||
|
recordCount: number;
|
||||||
|
@ViewColumn()
|
||||||
|
totalPointSum: number;
|
||||||
|
@ViewColumn()
|
||||||
|
result: number;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue