ผูกสิดข้อมูลหลัก
This commit is contained in:
parent
f9fce4ba25
commit
92b2291c4b
15 changed files with 702 additions and 514 deletions
|
|
@ -69,7 +69,7 @@ export class kpiCapacityController extends Controller {
|
||||||
},
|
},
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiCapacity = Object.assign(new KpiCapacity(), {
|
const kpiCapacity = Object.assign(new KpiCapacity(), {
|
||||||
type: requestBody.type,
|
type: requestBody.type,
|
||||||
name: requestBody.name,
|
name: requestBody.name,
|
||||||
|
|
@ -134,7 +134,7 @@ export class kpiCapacityController extends Controller {
|
||||||
},
|
},
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -285,7 +285,8 @@ export class kpiCapacityController extends Controller {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
async GetKpiCapacityById(@Path() id: string) {
|
async GetKpiCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["type", "name", "description"],
|
select: ["type", "name", "description"],
|
||||||
|
|
@ -315,11 +316,13 @@ export class kpiCapacityController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiCapacity(
|
async listKpiCapacity(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("type") type?: string,
|
@Query("type") type?: string,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
||||||
.createQueryBuilder("kpiCapacity")
|
.createQueryBuilder("kpiCapacity")
|
||||||
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
||||||
|
|
@ -360,7 +363,7 @@ export class kpiCapacityController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiCapacity(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteKpiCapacity(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
Post,
|
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
Tags,
|
||||||
Body,
|
Body,
|
||||||
Path,
|
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
|
|
@ -18,7 +14,7 @@ import {
|
||||||
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 { Like, Not } from "typeorm";
|
import { Like } from "typeorm";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { KpiEvaluation, updateKpiEvaluation } from "../entities/kpiEvaluation";
|
import { KpiEvaluation, updateKpiEvaluation } from "../entities/kpiEvaluation";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
|
|
@ -43,7 +39,7 @@ export class kpiEvaluationController extends Controller {
|
||||||
@Body() requestBody: updateKpiEvaluation[],
|
@Body() requestBody: updateKpiEvaluation[],
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||||
const updatedIds: string[] = [];
|
const updatedIds: string[] = [];
|
||||||
|
|
||||||
for (const item of requestBody) {
|
for (const item of requestBody) {
|
||||||
|
|
@ -70,10 +66,12 @@ export class kpiEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiEvaluation(
|
async listKpiEvaluation(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
let whereClause: any = {};
|
let whereClause: any = {};
|
||||||
|
|
||||||
if (keyword !== undefined && keyword !== "") {
|
if (keyword !== undefined && keyword !== "") {
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,8 @@ export class kpiGroupController extends Controller {
|
||||||
@Example({
|
@Example({
|
||||||
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
||||||
})
|
})
|
||||||
async createKpiGroup(
|
async createKpiGroup(@Body() requestBody: createKpiGroup, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: createKpiGroup,
|
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
|
|
||||||
const kpiGroup = Object.assign(new KpiGroup(), requestBody);
|
const kpiGroup = Object.assign(new KpiGroup(), requestBody);
|
||||||
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -75,7 +72,7 @@ export class kpiGroupController extends Controller {
|
||||||
@Body() requestBody: updateKpiGroup,
|
@Body() requestBody: updateKpiGroup,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -86,7 +83,7 @@ export class kpiGroupController extends Controller {
|
||||||
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
nameGroupKPI: requestBody.nameGroupKPI,
|
nameGroupKPI: requestBody.nameGroupKPI,
|
||||||
id: Not(id)
|
id: Not(id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chkkpinameGroup) {
|
if (chkkpinameGroup) {
|
||||||
|
|
@ -107,7 +104,8 @@ export class kpiGroupController extends Controller {
|
||||||
@Example({
|
@Example({
|
||||||
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
||||||
})
|
})
|
||||||
async KpiGroupById(@Path() id: string) {
|
async KpiGroupById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["nameGroupKPI"],
|
select: ["nameGroupKPI"],
|
||||||
|
|
@ -124,7 +122,7 @@ export class kpiGroupController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiGroup(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteKpiGroup(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -143,10 +141,12 @@ export class kpiGroupController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiGroup(
|
async listKpiGroup(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
let whereClause: any = {};
|
let whereClause: any = {};
|
||||||
|
|
||||||
if (keyword !== undefined && keyword !== "") {
|
if (keyword !== undefined && keyword !== "") {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
|
|
@ -18,9 +17,9 @@ import {
|
||||||
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 { Like, Not, In, Brackets } from "typeorm";
|
import { In, Brackets } from "typeorm";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { KpiLink, createKpiLink, updateKpiLink } from "../entities/kpiLink";
|
import { KpiLink, createKpiLink } from "../entities/kpiLink";
|
||||||
import { KpiGroup } from "../entities/kpiGroup";
|
import { KpiGroup } from "../entities/kpiGroup";
|
||||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||||
import { Position } from "../entities/position";
|
import { Position } from "../entities/position";
|
||||||
|
|
@ -165,7 +164,8 @@ export class kpiLinkController extends Controller {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async KpiLinkById(@Path() id: string) {
|
async KpiLinkById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiLink = await this.kpiLinkRepository.findOne({
|
const kpiLink = await this.kpiLinkRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
||||||
|
|
@ -224,10 +224,12 @@ export class kpiLinkController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiLink(
|
async listKpiLink(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||||
const [_kpiLink, _total] = await AppDataSource.getRepository(KpiLink)
|
const [_kpiLink, _total] = await AppDataSource.getRepository(KpiLink)
|
||||||
.createQueryBuilder("kpiLink")
|
.createQueryBuilder("kpiLink")
|
||||||
.leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup")
|
.leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup")
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -22,7 +20,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { KpiPlan, createKpiPlan, updateKpiPlan } from "../entities/kpiPlan";
|
import { KpiPlan, createKpiPlan, updateKpiPlan } from "../entities/kpiPlan";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { KpiPeriod } from "../entities/kpiPeriod";
|
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||||
import { Brackets, IsNull, Not } from "typeorm";
|
import { Brackets, IsNull } from "typeorm";
|
||||||
import { KpiPlanHistory } from "../entities/kpiPlanHistory";
|
import { KpiPlanHistory } from "../entities/kpiPlanHistory";
|
||||||
import { KpiSpecial } from "../entities/kpiSpecial";
|
import { KpiSpecial } from "../entities/kpiSpecial";
|
||||||
import { KpiRole } from "../entities/kpiRole";
|
import { KpiRole } from "../entities/kpiRole";
|
||||||
|
|
@ -48,11 +46,8 @@ export class kpiPlanController extends Controller {
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
@Post()
|
@Post()
|
||||||
async createKpiPlan(
|
async createKpiPlan(@Body() requestBody: createKpiPlan, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: createKpiPlan,
|
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
|
||||||
const kpiPlan = Object.assign(new KpiPlan(), requestBody);
|
const kpiPlan = Object.assign(new KpiPlan(), requestBody);
|
||||||
if (requestBody.year != null && requestBody.period != null) {
|
if (requestBody.year != null && requestBody.period != null) {
|
||||||
const kpiPeriod = await this.kpiPeriodRepository
|
const kpiPeriod = await this.kpiPeriodRepository
|
||||||
|
|
@ -212,7 +207,7 @@ export class kpiPlanController extends Controller {
|
||||||
@Body() requestBody: updateKpiPlan,
|
@Body() requestBody: updateKpiPlan,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -294,7 +289,8 @@ export class kpiPlanController extends Controller {
|
||||||
* @param id Guid, *Id ตัวชี้วัดตามแผนฯ
|
* @param id Guid, *Id ตัวชี้วัดตามแผนฯ
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiPlanById(@Path() id: string) {
|
async GetKpiPlanById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: { kpiPeriod: true },
|
relations: { kpiPeriod: true },
|
||||||
|
|
@ -398,6 +394,7 @@ export class kpiPlanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search")
|
@Post("search")
|
||||||
async listKpiPlan(
|
async listKpiPlan(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
page: number;
|
page: number;
|
||||||
|
|
@ -411,6 +408,7 @@ export class kpiPlanController extends Controller {
|
||||||
// isNull?: boolean | false;
|
// isNull?: boolean | false;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
let condition = "";
|
let condition = "";
|
||||||
let parameters: any = {};
|
let parameters: any = {};
|
||||||
if (requestBody.isAll === false) {
|
if (requestBody.isAll === false) {
|
||||||
|
|
@ -506,7 +504,7 @@ export class kpiPlanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiPlan(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteKpiPlan(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -592,7 +590,8 @@ export class kpiPlanController extends Controller {
|
||||||
* @param id Guid, *Id ประวัดิตัวชี้วัดตามแผน
|
* @param id Guid, *Id ประวัดิตัวชี้วัดตามแผน
|
||||||
*/
|
*/
|
||||||
@Get("history/{id}")
|
@Get("history/{id}")
|
||||||
async GetHistory(@Path() id: string) {
|
async GetHistory(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
|
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
|
||||||
where: { kpiPlanId: id },
|
where: { kpiPlanId: id },
|
||||||
order: {
|
order: {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import {
|
||||||
updateKpiUserReasonEvaluation,
|
updateKpiUserReasonEvaluation,
|
||||||
} from "../entities/kpiUserEvaluationReasonCapacity";
|
} from "../entities/kpiUserEvaluationReasonCapacity";
|
||||||
import { KpiUserEvaluationReasonDevelopment } from "../entities/kpiUserEvaluationReasonDevelopment";
|
import { KpiUserEvaluationReasonDevelopment } from "../entities/kpiUserEvaluationReasonDevelopment";
|
||||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
|
||||||
import { KpiUserRole } from "../entities/kpiUserRole";
|
import { KpiUserRole } from "../entities/kpiUserRole";
|
||||||
import { KpiUserSpecial } from "../entities/kpiUserSpecial";
|
import { KpiUserSpecial } from "../entities/kpiUserSpecial";
|
||||||
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -44,11 +42,8 @@ export class kpiRoleController extends Controller {
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
@Post()
|
@Post()
|
||||||
async createKpiRole(
|
async createKpiRole(@Body() requestBody: createKpiRole, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: createKpiRole,
|
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
|
||||||
const kpiRole = Object.assign(new KpiRole(), requestBody);
|
const kpiRole = Object.assign(new KpiRole(), requestBody);
|
||||||
if (requestBody.year != null && requestBody.period != null) {
|
if (requestBody.year != null && requestBody.period != null) {
|
||||||
const kpiPeriod = await this.kpiPeriodRepository
|
const kpiPeriod = await this.kpiPeriodRepository
|
||||||
|
|
@ -205,7 +200,7 @@ export class kpiRoleController extends Controller {
|
||||||
@Body() requestBody: updateKpiRole,
|
@Body() requestBody: updateKpiRole,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -269,7 +264,8 @@ export class kpiRoleController extends Controller {
|
||||||
* @param id Guid, *Id ตัวชี้วัดตามตำแหน่ง
|
* @param id Guid, *Id ตัวชี้วัดตามตำแหน่ง
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiRoleById(@Path() id: string) {
|
async GetKpiRoleById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: { kpiPeriod: true },
|
relations: { kpiPeriod: true },
|
||||||
|
|
@ -343,6 +339,7 @@ export class kpiRoleController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search")
|
@Post("search")
|
||||||
async listKpiRole(
|
async listKpiRole(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
page: number;
|
page: number;
|
||||||
|
|
@ -357,6 +354,7 @@ export class kpiRoleController extends Controller {
|
||||||
// isNull?: boolean | false;
|
// isNull?: boolean | false;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
let condition = "";
|
let condition = "";
|
||||||
let parameters: any = {};
|
let parameters: any = {};
|
||||||
if (requestBody.isAll === false) {
|
if (requestBody.isAll === false) {
|
||||||
|
|
@ -468,8 +466,8 @@ export class kpiRoleController extends Controller {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiRole(@Path() id: string,@Request() request: RequestWithUser) {
|
async deleteKpiRole(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -559,7 +557,8 @@ export class kpiRoleController extends Controller {
|
||||||
* @param id Guid, *Id ประวัดิตัวชี้วัดตามตำแหน่ง
|
* @param id Guid, *Id ประวัดิตัวชี้วัดตามตำแหน่ง
|
||||||
*/
|
*/
|
||||||
@Get("history/{id}")
|
@Get("history/{id}")
|
||||||
async GetHistory(@Path() id: string) {
|
async GetHistory(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiRoleHistory = await this.kpiRoleHistoryRepository.find({
|
const kpiRoleHistory = await this.kpiRoleHistoryRepository.find({
|
||||||
where: { kpiRoleId: id },
|
where: { kpiRoleId: id },
|
||||||
order: {
|
order: {
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,15 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
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 { KpiSpecial, CreateKpiSpecial, UpdateKpiSpecial } from "../entities/kpiSpecial";
|
import { KpiSpecial, CreateKpiSpecial, UpdateKpiSpecial } from "../entities/kpiSpecial";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import { Brackets, Not } from "typeorm";
|
||||||
import { Brackets, IsNull, Like, Not } from "typeorm";
|
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
@Route("api/v1/kpi/special")
|
@Route("api/v1/kpi/special")
|
||||||
|
|
@ -45,7 +42,7 @@ export class kpiSpecialController extends Controller {
|
||||||
@Body() requestBody: CreateKpiSpecial,
|
@Body() requestBody: CreateKpiSpecial,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
including: String(requestBody.including),
|
including: String(requestBody.including),
|
||||||
|
|
@ -82,7 +79,7 @@ export class kpiSpecialController extends Controller {
|
||||||
@Body() requestBody: UpdateKpiSpecial,
|
@Body() requestBody: UpdateKpiSpecial,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -115,7 +112,8 @@ export class kpiSpecialController extends Controller {
|
||||||
* @param id Guid, *Id ตัวชี้วัด Special
|
* @param id Guid, *Id ตัวชี้วัด Special
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiSpecialById(@Path() id: string) {
|
async GetKpiSpecialById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -156,6 +154,7 @@ export class kpiSpecialController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search")
|
@Post("search")
|
||||||
async listKpiSpecial(
|
async listKpiSpecial(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
page: number;
|
page: number;
|
||||||
|
|
@ -165,6 +164,7 @@ export class kpiSpecialController extends Controller {
|
||||||
keyword?: string | null;
|
keyword?: string | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||||
// let condition: any = {};
|
// let condition: any = {};
|
||||||
// if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
// if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
||||||
// condition = {
|
// condition = {
|
||||||
|
|
@ -216,8 +216,8 @@ export class kpiSpecialController extends Controller {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiSpecial(@Path() id: string, @Request() request: RequestWithUser,) {
|
async deleteKpiSpecial(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,9 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
ArrayValidator,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -23,11 +21,9 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||||
import { KpiUserCapacity, KpiUserCapacityDataPoint } from "../entities/kpiUserCapacity";
|
import { KpiUserCapacity, KpiUserCapacityDataPoint } from "../entities/kpiUserCapacity";
|
||||||
import { Like, In, Not } from "typeorm";
|
import { Not } from "typeorm";
|
||||||
import { Double } from "typeorm/browser";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { request } from "axios";
|
|
||||||
|
|
||||||
@Route("api/v1/kpi/user/capacity")
|
@Route("api/v1/kpi/user/capacity")
|
||||||
@Tags("kpiUserCapacity")
|
@Tags("kpiUserCapacity")
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import {
|
||||||
} from "../entities/kpiUserDevelopment";
|
} from "../entities/kpiUserDevelopment";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||||
import { Not, Like, Brackets } from "typeorm";
|
import { Not, Brackets } from "typeorm";
|
||||||
import { DevelopmentProject } from "../entities/developmentProject";
|
import { DevelopmentProject } from "../entities/developmentProject";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,9 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
ArrayValidator,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -31,7 +29,7 @@ import {
|
||||||
updateKpiUserReqEditEvaluation,
|
updateKpiUserReqEditEvaluation,
|
||||||
updateKpiUserResultEvaluation,
|
updateKpiUserResultEvaluation,
|
||||||
} from "../entities/kpiUserEvaluation";
|
} from "../entities/kpiUserEvaluation";
|
||||||
import { Like, In, Brackets, IsNull, Not } from "typeorm";
|
import { In, Brackets, IsNull, Not } from "typeorm";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||||
import { Position } from "../entities/position";
|
import { Position } from "../entities/position";
|
||||||
|
|
@ -249,27 +247,27 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere(conditionFullName, {
|
.orWhere(conditionFullName, {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
})
|
});
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,12 @@ import {
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
Delete,
|
||||||
Patch,
|
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
Tags,
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,12 @@ import {
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Delete,
|
Delete,
|
||||||
Patch,
|
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
Tags,
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
Example,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Query,
|
Query,
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,11 @@
|
||||||
import {
|
import { Controller, Get, Post, Route, Security, Tags, Body, Path, Request } from "tsoa";
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Delete,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Path,
|
|
||||||
Request,
|
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Brackets, IsNull, Not, In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
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 { KpiPeriod } from "../entities/kpiPeriod";
|
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||||
import { off } from "process";
|
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
import { KpiRole } from "../entities/kpiRole";
|
import { KpiRole } from "../entities/kpiRole";
|
||||||
import { KpiPlan } from "../entities/kpiPlan";
|
import { KpiPlan } from "../entities/kpiPlan";
|
||||||
|
|
@ -75,7 +61,7 @@ export class ReportController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
kpiPeriodId: requestBody.periodId,
|
kpiPeriodId: requestBody.periodId,
|
||||||
orgId: requestBody.root,
|
orgId: requestBody.root,
|
||||||
evaluationStatus: "KP7"
|
evaluationStatus: "KP7",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -121,7 +107,7 @@ export class ReportController extends Controller {
|
||||||
const userEvaluationOrg = await this.kpiUserEvaluationRepository.find({
|
const userEvaluationOrg = await this.kpiUserEvaluationRepository.find({
|
||||||
where: {
|
where: {
|
||||||
orgId: String(requestBody?.root),
|
orgId: String(requestBody?.root),
|
||||||
kpiPeriodId: String(requestBody?.periodId)
|
kpiPeriodId: String(requestBody?.periodId),
|
||||||
// child1Id: "" || IsNull(),
|
// child1Id: "" || IsNull(),
|
||||||
// child2Id: "" || IsNull(),
|
// child2Id: "" || IsNull(),
|
||||||
// child3Id: "" || IsNull(),
|
// child3Id: "" || IsNull(),
|
||||||
|
|
@ -135,16 +121,16 @@ export class ReportController extends Controller {
|
||||||
const result =
|
const result =
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg.filter((x: any) => x.evaluationStatus == "KP7").length.toString(),
|
||||||
.filter((x: any) => x.evaluationStatus == "KP7")
|
|
||||||
.length.toString(),
|
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
const excellent =
|
const excellent =
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg
|
||||||
.filter((x: any) => x.evaluationResults == "EXCELLENT" && x.evaluationStatus == "KP7")
|
.filter(
|
||||||
|
(x: any) => x.evaluationResults == "EXCELLENT" && x.evaluationStatus == "KP7",
|
||||||
|
)
|
||||||
.length.toString(),
|
.length.toString(),
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
|
|
@ -152,7 +138,9 @@ export class ReportController extends Controller {
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg
|
||||||
.filter((x: any) => x.evaluationResults == "VERY_GOOD" && x.evaluationStatus == "KP7")
|
.filter(
|
||||||
|
(x: any) => x.evaluationResults == "VERY_GOOD" && x.evaluationStatus == "KP7",
|
||||||
|
)
|
||||||
.length.toString(),
|
.length.toString(),
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
|
|
@ -160,23 +148,25 @@ export class ReportController extends Controller {
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg
|
||||||
.filter((x: any) => x.evaluationResults == "GOOD" && x.evaluationStatus == "KP7")
|
.filter((x: any) => x.evaluationResults == "GOOD" && x.evaluationStatus == "KP7")
|
||||||
.length.toString(),
|
.length.toString(),
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
const fair =
|
const fair =
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg
|
||||||
.filter((x: any) => x.evaluationResults == "FAIR" && x.evaluationStatus == "KP7")
|
.filter((x: any) => x.evaluationResults == "FAIR" && x.evaluationStatus == "KP7")
|
||||||
.length.toString(),
|
.length.toString(),
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
const improvment =
|
const improvment =
|
||||||
userEvaluationOrg.length > 0
|
userEvaluationOrg.length > 0
|
||||||
? Extension.ToThaiNumber(
|
? Extension.ToThaiNumber(
|
||||||
userEvaluationOrg
|
userEvaluationOrg
|
||||||
.filter((x: any) => x.evaluationResults == "IMPROVEMENT" && x.evaluationStatus == "KP7")
|
.filter(
|
||||||
|
(x: any) => x.evaluationResults == "IMPROVEMENT" && x.evaluationStatus == "KP7",
|
||||||
|
)
|
||||||
.length.toString(),
|
.length.toString(),
|
||||||
)
|
)
|
||||||
: "๐";
|
: "๐";
|
||||||
|
|
@ -481,103 +471,103 @@ export class ReportController extends Controller {
|
||||||
.select("MIN(kpiUserEvaluation.id) as id")
|
.select("MIN(kpiUserEvaluation.id) as id")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
// const profileEvaluationNextYearIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
// const profileEvaluationNextYearIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
// .createQueryBuilder("kpiUserEvaluation")
|
// .createQueryBuilder("kpiUserEvaluation")
|
||||||
// .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
// .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
// .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId })
|
// .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId })
|
||||||
// .where("kpiPeriod.year = :year", { year: yearNow + 1 })
|
// .where("kpiPeriod.year = :year", { year: yearNow + 1 })
|
||||||
// .groupBy("kpiUserEvaluation.kpiPeriodId")
|
// .groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||||
// .select("MIN(kpiUserEvaluation.id) as id")
|
// .select("MIN(kpiUserEvaluation.id) as id")
|
||||||
// .getRawMany();
|
// .getRawMany();
|
||||||
// const profileEvaluationCombianIds = profileEvaluationNowYearIds.concat(profileEvaluationNextYearIds);
|
// const profileEvaluationCombianIds = profileEvaluationNowYearIds.concat(profileEvaluationNextYearIds);
|
||||||
|
|
||||||
//ชั่วคราว
|
//ชั่วคราว
|
||||||
const profileEvaluations = await this.kpiUserEvaluationRepository.find({
|
const profileEvaluations = await this.kpiUserEvaluationRepository.find({
|
||||||
relations: ["kpiPeriod"],
|
relations: ["kpiPeriod"],
|
||||||
where: { id: In(profileEvaluationNowYearIds.map((evaluation) => evaluation.id)) },
|
where: { id: In(profileEvaluationNowYearIds.map((evaluation) => evaluation.id)) },
|
||||||
});
|
});
|
||||||
|
|
||||||
const groupedEvaluations = profileEvaluations.reduce((acc: any, evaluation: any) => {
|
const groupedEvaluations = profileEvaluations.reduce((acc: any, evaluation: any) => {
|
||||||
const year = evaluation.kpiPeriod.year;
|
const year = evaluation.kpiPeriod.year;
|
||||||
const profileId = evaluation.profileId;
|
const profileId = evaluation.profileId;
|
||||||
const key = `${profileId}-${year}`;
|
const key = `${profileId}-${year}`;
|
||||||
|
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = {
|
acc[key] = {
|
||||||
fullName: evaluation.prefix + evaluation.firstName + " " + evaluation.lastName,
|
fullName: evaluation.prefix + evaluation.firstName + " " + evaluation.lastName,
|
||||||
profileId: profileId,
|
profileId: profileId,
|
||||||
year: year ? Extension.ToThaiNumber(Extension.ToThaiYear(year).toString()) : null,
|
year: year ? Extension.ToThaiNumber(Extension.ToThaiYear(year).toString()) : null,
|
||||||
evaluations: [],
|
evaluations: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
acc[key].evaluations.push(evaluation);
|
acc[key].evaluations.push(evaluation);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// สร้าง formatData
|
// สร้าง formatData
|
||||||
combinedDatas = Object.values(groupedEvaluations).map((group: any) => {
|
combinedDatas = Object.values(groupedEvaluations).map((group: any) => {
|
||||||
const data: any = {
|
const data: any = {
|
||||||
fullName: group.fullName ?? null,
|
fullName: group.fullName ?? null,
|
||||||
year: group.year ?? null,
|
year: group.year ?? null,
|
||||||
};
|
};
|
||||||
|
|
||||||
group.evaluations.forEach((evaluation: any) => {
|
group.evaluations.forEach((evaluation: any) => {
|
||||||
if (evaluation.kpiPeriod.durationKPI === "APR") {
|
if (evaluation.kpiPeriod.durationKPI === "APR") {
|
||||||
data.summaryPointAPR1 =
|
data.summaryPointAPR1 =
|
||||||
evaluation.summaryPoint >= 90
|
evaluation.summaryPoint >= 90
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointAPR2 =
|
data.summaryPointAPR2 =
|
||||||
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointAPR3 =
|
data.summaryPointAPR3 =
|
||||||
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointAPR4 =
|
data.summaryPointAPR4 =
|
||||||
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointAPR5 =
|
data.summaryPointAPR5 =
|
||||||
evaluation.summaryPoint < 60
|
evaluation.summaryPoint < 60
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.periodAPR = evaluation.kpiPeriod.durationKPI;
|
data.periodAPR = evaluation.kpiPeriod.durationKPI;
|
||||||
} else if (evaluation.kpiPeriod.durationKPI === "OCT") {
|
} else if (evaluation.kpiPeriod.durationKPI === "OCT") {
|
||||||
data.summaryPointOCT1 =
|
data.summaryPointOCT1 =
|
||||||
evaluation.summaryPoint >= 90
|
evaluation.summaryPoint >= 90
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointOCT2 =
|
data.summaryPointOCT2 =
|
||||||
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointOCT3 =
|
data.summaryPointOCT3 =
|
||||||
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointOCT4 =
|
data.summaryPointOCT4 =
|
||||||
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.summaryPointOCT5 =
|
data.summaryPointOCT5 =
|
||||||
evaluation.summaryPoint < 60
|
evaluation.summaryPoint < 60
|
||||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||||
: null;
|
: null;
|
||||||
data.periodOCT = evaluation.kpiPeriod.durationKPI ?? null;
|
data.periodOCT = evaluation.kpiPeriod.durationKPI ?? null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
formattedData = {
|
formattedData = {
|
||||||
combinedDatas: combinedDatas.length > 0 ? combinedDatas : [{}],
|
combinedDatas: combinedDatas.length > 0 ? combinedDatas : [{}],
|
||||||
fullName: combinedDatas.length > 0?combinedDatas[0]["fullName"]:"-",
|
fullName: combinedDatas.length > 0 ? combinedDatas[0]["fullName"] : "-",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (requestBody.type == "KPI5") {
|
if (requestBody.type == "KPI5") {
|
||||||
templateName = "KPI5";
|
templateName = "KPI5";
|
||||||
|
|
@ -651,164 +641,193 @@ export class ReportController extends Controller {
|
||||||
.select("MIN(kpiUserEvaluation.id) as id")
|
.select("MIN(kpiUserEvaluation.id) as id")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
// if (profileEvaluationIds.length > 0) {
|
// if (profileEvaluationIds.length > 0) {
|
||||||
const profileEvaluation = await this.kpiUserEvaluationRepository.find({
|
const profileEvaluation = await this.kpiUserEvaluationRepository.find({
|
||||||
relations: ["kpiPeriod"],
|
relations: ["kpiPeriod"],
|
||||||
where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) },
|
where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) },
|
||||||
});
|
});
|
||||||
|
|
||||||
const combinedData: KPIData = profileEvaluation.reduce(
|
const combinedData: KPIData = profileEvaluation.reduce(
|
||||||
(acc: KPIData, x) => {
|
(acc: KPIData, x) => {
|
||||||
const fullNameParts = [x.child4, x.child3, x.child2, x.child1, x.org];
|
const fullNameParts = [x.child4, x.child3, x.child2, x.child1, x.org];
|
||||||
|
|
||||||
const affiliation = fullNameParts
|
const affiliation = fullNameParts
|
||||||
.filter((part) => part !== undefined && part !== null)
|
.filter((part) => part !== undefined && part !== null)
|
||||||
.join("/");
|
.join("/");
|
||||||
|
|
||||||
if (!acc.fullName) {
|
if (!acc.fullName) {
|
||||||
acc.fullName = x.prefix + " " + x.firstName + " " + x.lastName;
|
acc.fullName = x.prefix + " " + x.firstName + " " + x.lastName;
|
||||||
acc.position = x.position;
|
acc.position = x.position;
|
||||||
acc.posType = x.posTypeName;
|
acc.posType = x.posTypeName;
|
||||||
acc.posLevel = x.posLevelName;
|
acc.posLevel = x.posLevelName;
|
||||||
acc.affiliation = affiliation;
|
acc.affiliation = affiliation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 4 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 4 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR1 = x.summaryPoint
|
acc.summaryPointAPR1 = x.summaryPoint
|
||||||
? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.textPointAPR1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
: null;
|
||||||
acc.periodAPR1 = x.kpiPeriod.durationKPI;
|
acc.textPointAPR1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
acc.yearAPR1 =
|
acc.periodAPR1 = x.kpiPeriod.durationKPI;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.yearAPR1 = x.kpiPeriod.year
|
||||||
}
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 4 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 4 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT1 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointOCT1 = x.summaryPoint
|
||||||
acc.textPointOCT1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT1 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT1 =
|
acc.textPointOCT1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodOCT1 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT1 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR2 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointAPR2 = x.summaryPoint
|
||||||
acc.textPointAPR2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR2 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR2 =
|
acc.textPointAPR2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodAPR2 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR2 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT2 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointOCT2 = x.summaryPoint
|
||||||
acc.textPointOCT2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT2 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT2 =
|
acc.textPointOCT2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodOCT2 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT2 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR3 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointAPR3 = x.summaryPoint
|
||||||
acc.textPointAPR3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR3 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR3 =
|
acc.textPointAPR3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodAPR3 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR3 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT3 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointOCT3 = x.summaryPoint
|
||||||
acc.textPointOCT3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT3 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT3 =
|
acc.textPointOCT3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodOCT3 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT3 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR4 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointAPR4 = x.summaryPoint
|
||||||
acc.textPointAPR4 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR4 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR4 =
|
acc.textPointAPR4 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodAPR4 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR4 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT4 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointOCT4 = x.summaryPoint
|
||||||
acc.textPointOCT4 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT4 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT4 =
|
acc.textPointOCT4 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodOCT4 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT4 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR5 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointAPR5 = x.summaryPoint
|
||||||
acc.textPointAPR5 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR5 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR5 =
|
acc.textPointAPR5 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodAPR5 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR5 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT5 = x.summaryPoint ? Extension.ToThaiNumber(x.summaryPoint.toString()) : null;
|
acc.summaryPointOCT5 = x.summaryPoint
|
||||||
acc.textPointOCT5 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT5 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT5 =
|
acc.textPointOCT5 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null;
|
acc.periodOCT5 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT5 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fullName: null,
|
fullName: null,
|
||||||
position: null,
|
position: null,
|
||||||
posType: null,
|
posType: null,
|
||||||
posLevel: null,
|
posLevel: null,
|
||||||
affiliation: null,
|
affiliation: null,
|
||||||
summaryPointAPR1: null,
|
summaryPointAPR1: null,
|
||||||
textPointAPR1: null,
|
textPointAPR1: null,
|
||||||
periodAPR1: null,
|
periodAPR1: null,
|
||||||
yearAPR1: null,
|
yearAPR1: null,
|
||||||
summaryPointOCT1: null,
|
summaryPointOCT1: null,
|
||||||
textPointOCT1: null,
|
textPointOCT1: null,
|
||||||
periodOCT1: null,
|
periodOCT1: null,
|
||||||
yearOCT1: null,
|
yearOCT1: null,
|
||||||
summaryPointAPR2: null,
|
summaryPointAPR2: null,
|
||||||
textPointAPR2: null,
|
textPointAPR2: null,
|
||||||
periodAPR2: null,
|
periodAPR2: null,
|
||||||
yearAPR2: null,
|
yearAPR2: null,
|
||||||
summaryPointOCT2: null,
|
summaryPointOCT2: null,
|
||||||
textPointOCT2: null,
|
textPointOCT2: null,
|
||||||
periodOCT2: null,
|
periodOCT2: null,
|
||||||
yearOCT2: null,
|
yearOCT2: null,
|
||||||
summaryPointAPR3: null,
|
summaryPointAPR3: null,
|
||||||
textPointAPR3: null,
|
textPointAPR3: null,
|
||||||
periodAPR3: null,
|
periodAPR3: null,
|
||||||
yearAPR3: null,
|
yearAPR3: null,
|
||||||
summaryPointOCT3: null,
|
summaryPointOCT3: null,
|
||||||
textPointOCT3: null,
|
textPointOCT3: null,
|
||||||
periodOCT3: null,
|
periodOCT3: null,
|
||||||
yearOCT3: null,
|
yearOCT3: null,
|
||||||
summaryPointAPR4: null,
|
summaryPointAPR4: null,
|
||||||
textPointAPR4: null,
|
textPointAPR4: null,
|
||||||
periodAPR4: null,
|
periodAPR4: null,
|
||||||
yearAPR4: null,
|
yearAPR4: null,
|
||||||
summaryPointOCT4: null,
|
summaryPointOCT4: null,
|
||||||
textPointOCT4: null,
|
textPointOCT4: null,
|
||||||
periodOCT4: null,
|
periodOCT4: null,
|
||||||
yearOCT4: null,
|
yearOCT4: null,
|
||||||
summaryPointAPR5: null,
|
summaryPointAPR5: null,
|
||||||
textPointAPR5: null,
|
textPointAPR5: null,
|
||||||
periodAPR5: null,
|
periodAPR5: null,
|
||||||
yearAPR5: null,
|
yearAPR5: null,
|
||||||
summaryPointOCT5: null,
|
summaryPointOCT5: null,
|
||||||
textPointOCT5: null,
|
textPointOCT5: null,
|
||||||
periodOCT5: null,
|
periodOCT5: null,
|
||||||
yearOCT5: null,
|
yearOCT5: null,
|
||||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()),
|
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()),
|
||||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()),
|
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()),
|
||||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||||
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||||
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
formattedData = combinedData;
|
formattedData = combinedData;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -867,113 +886,131 @@ export class ReportController extends Controller {
|
||||||
.select("MIN(kpiUserEvaluation.id) as id")
|
.select("MIN(kpiUserEvaluation.id) as id")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
// if (profileEvaluationIds.length > 0) {
|
// if (profileEvaluationIds.length > 0) {
|
||||||
const profileEvaluation = await this.kpiUserEvaluationRepository.find({
|
const profileEvaluation = await this.kpiUserEvaluationRepository.find({
|
||||||
relations: ["kpiPeriod"],
|
relations: ["kpiPeriod"],
|
||||||
where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) },
|
where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) },
|
||||||
});
|
});
|
||||||
|
|
||||||
const combinedData: KPIData = profileEvaluation.reduce(
|
const combinedData: KPIData = profileEvaluation.reduce(
|
||||||
(acc: KPIData, x) => {
|
(acc: KPIData, x) => {
|
||||||
const fullNameParts = [x.child4, x.child3, x.child2, x.child1, x.org];
|
const fullNameParts = [x.child4, x.child3, x.child2, x.child1, x.org];
|
||||||
|
|
||||||
const affiliation = fullNameParts
|
const affiliation = fullNameParts
|
||||||
.filter((part) => part !== undefined && part !== null)
|
.filter((part) => part !== undefined && part !== null)
|
||||||
.join("/");
|
.join("/");
|
||||||
|
|
||||||
if (!acc.fullName) {
|
if (!acc.fullName) {
|
||||||
acc.fullName = x.prefix + " " + x.firstName + " " + x.lastName;
|
acc.fullName = x.prefix + " " + x.firstName + " " + x.lastName;
|
||||||
acc.position = x.position;
|
acc.position = x.position;
|
||||||
acc.posType = x.posTypeName;
|
acc.posType = x.posTypeName;
|
||||||
acc.posLevel = x.posLevelName;
|
acc.posLevel = x.posLevelName;
|
||||||
acc.affiliation = affiliation;
|
acc.affiliation = affiliation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR1 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointAPR1 = x.summaryPoint
|
||||||
acc.textPointAPR1 = x.summaryPoint?Extension.textPoint(x.summaryPoint):null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR1 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR1 =
|
acc.textPointAPR1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodAPR1 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR1 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT1 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointOCT1 = x.summaryPoint
|
||||||
acc.textPointOCT1 = x.summaryPoint?Extension.textPoint(x.summaryPoint) : null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT1 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT1 =
|
acc.textPointOCT1 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodOCT1 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT1 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR2 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointAPR2 = x.summaryPoint
|
||||||
acc.textPointAPR2 = x.summaryPoint?Extension.textPoint(x.summaryPoint):null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR2 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR2 =
|
acc.textPointAPR2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodAPR2 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR2 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT2 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointOCT2 = x.summaryPoint
|
||||||
acc.textPointOCT2 = x.summaryPoint?Extension.textPoint(x.summaryPoint):null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT2 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT2 =
|
acc.textPointOCT2 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodOCT2 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT2 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") {
|
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") {
|
||||||
acc.summaryPointAPR3 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointAPR3 = x.summaryPoint
|
||||||
acc.textPointAPR3 = x.summaryPoint?Extension.textPoint(x.summaryPoint):null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodAPR3 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearAPR3 =
|
acc.textPointAPR3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodAPR3 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearAPR3 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") {
|
if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") {
|
||||||
acc.summaryPointOCT3 = x.summaryPoint?Extension.ToThaiNumber(x.summaryPoint.toString()):null;
|
acc.summaryPointOCT3 = x.summaryPoint
|
||||||
acc.textPointOCT3 = x.summaryPoint?Extension.textPoint(x.summaryPoint):null;
|
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||||
acc.periodOCT3 = x.kpiPeriod.durationKPI;
|
: null;
|
||||||
acc.yearOCT3 =
|
acc.textPointOCT3 = x.summaryPoint ? Extension.textPoint(x.summaryPoint) : null;
|
||||||
x.kpiPeriod.year?Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()):null;
|
acc.periodOCT3 = x.kpiPeriod.durationKPI;
|
||||||
}
|
acc.yearOCT3 = x.kpiPeriod.year
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fullName: null,
|
fullName: null,
|
||||||
position: null,
|
position: null,
|
||||||
posType: null,
|
posType: null,
|
||||||
posLevel: null,
|
posLevel: null,
|
||||||
affiliation: null,
|
affiliation: null,
|
||||||
summaryPointAPR1: null,
|
summaryPointAPR1: null,
|
||||||
textPointAPR1: null,
|
textPointAPR1: null,
|
||||||
periodAPR1: null,
|
periodAPR1: null,
|
||||||
yearAPR1: null,
|
yearAPR1: null,
|
||||||
summaryPointOCT1: null,
|
summaryPointOCT1: null,
|
||||||
textPointOCT1: null,
|
textPointOCT1: null,
|
||||||
periodOCT1: null,
|
periodOCT1: null,
|
||||||
yearOCT1: null,
|
yearOCT1: null,
|
||||||
summaryPointAPR2: null,
|
summaryPointAPR2: null,
|
||||||
textPointAPR2: null,
|
textPointAPR2: null,
|
||||||
periodAPR2: null,
|
periodAPR2: null,
|
||||||
yearAPR2: null,
|
yearAPR2: null,
|
||||||
summaryPointOCT2: null,
|
summaryPointOCT2: null,
|
||||||
textPointOCT2: null,
|
textPointOCT2: null,
|
||||||
periodOCT2: null,
|
periodOCT2: null,
|
||||||
yearOCT2: null,
|
yearOCT2: null,
|
||||||
summaryPointAPR3: null,
|
summaryPointAPR3: null,
|
||||||
textPointAPR3: null,
|
textPointAPR3: null,
|
||||||
periodAPR3: null,
|
periodAPR3: null,
|
||||||
yearAPR3: null,
|
yearAPR3: null,
|
||||||
summaryPointOCT3: null,
|
summaryPointOCT3: null,
|
||||||
textPointOCT3: null,
|
textPointOCT3: null,
|
||||||
periodOCT3: null,
|
periodOCT3: null,
|
||||||
yearOCT3: null,
|
yearOCT3: null,
|
||||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
formattedData = combinedData;
|
formattedData = combinedData;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -984,8 +1021,8 @@ export class ReportController extends Controller {
|
||||||
const userEvaluations_ = await Promise.all(
|
const userEvaluations_ = await Promise.all(
|
||||||
data.kpiUserEvaluations.length > 0
|
data.kpiUserEvaluations.length > 0
|
||||||
? data.kpiUserEvaluations.map(async (x: any, idx: number) => {
|
? data.kpiUserEvaluations.map(async (x: any, idx: number) => {
|
||||||
/*รอ Fe เพิ่ม UI*/
|
/*รอ Fe เพิ่ม UI*/
|
||||||
// const target_ = await this.kpiUserDevelopmentRepository.findOne({
|
// const target_ = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
// where: { kpiUserEvaluationId: x.id },
|
// where: { kpiUserEvaluationId: x.id },
|
||||||
// });
|
// });
|
||||||
// const isDev70 = target_ && target_?.isDevelopment70 === true
|
// const isDev70 = target_ && target_?.isDevelopment70 === true
|
||||||
|
|
@ -1034,18 +1071,18 @@ export class ReportController extends Controller {
|
||||||
templateName = "KPI8";
|
templateName = "KPI8";
|
||||||
reportName = "KPI8";
|
reportName = "KPI8";
|
||||||
//use_filter
|
//use_filter
|
||||||
let period_:any
|
let period_: any;
|
||||||
let formattedUserDevelopmentLists:any
|
let formattedUserDevelopmentLists: any;
|
||||||
let userInfo:any
|
let userInfo: any;
|
||||||
let userDevelopmentLists:any
|
let userDevelopmentLists: any;
|
||||||
let fullNameParts:any
|
let fullNameParts: any;
|
||||||
let affiliation:any
|
let affiliation: any;
|
||||||
if (requestBody.profileId && requestBody.periodId) {
|
if (requestBody.profileId && requestBody.periodId) {
|
||||||
period_ = await this.kpiPeriodRepository.findOne({
|
period_ = await this.kpiPeriodRepository.findOne({
|
||||||
where: { id: String(requestBody.periodId) }
|
where: { id: String(requestBody.periodId) },
|
||||||
})
|
});
|
||||||
if(period_ && !period1 && !period2) {
|
if (period_ && !period1 && !period2) {
|
||||||
if(period_?.durationKPI === "APR") {
|
if (period_?.durationKPI === "APR") {
|
||||||
period1 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
period1 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
||||||
let _period2 = await this.kpiPeriodRepository.findOne({
|
let _period2 = await this.kpiPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1057,8 +1094,7 @@ export class ReportController extends Controller {
|
||||||
period2 = _period2
|
period2 = _period2
|
||||||
? `${Extension.ToThaiFullDate2(_period2?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period2?.endDate)}`
|
? `${Extension.ToThaiFullDate2(_period2?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period2?.endDate)}`
|
||||||
: "";
|
: "";
|
||||||
}
|
} else if (period_?.durationKPI === "OCT") {
|
||||||
else if (period_?.durationKPI === "OCT"){
|
|
||||||
period2 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
period2 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
||||||
let _period1 = await this.kpiPeriodRepository.findOne({
|
let _period1 = await this.kpiPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1087,7 +1123,7 @@ export class ReportController extends Controller {
|
||||||
userInfo = await this.kpiUserEvaluationRepository.find({
|
userInfo = await this.kpiUserEvaluationRepository.find({
|
||||||
where: {
|
where: {
|
||||||
id: In(profileEvaluationIds.map((x: any) => x.id)),
|
id: In(profileEvaluationIds.map((x: any) => x.id)),
|
||||||
evaluationStatus: "KP7"
|
evaluationStatus: "KP7",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
userDevelopmentLists = await this.kpiUserDevelopmentRepository.find({
|
userDevelopmentLists = await this.kpiUserDevelopmentRepository.find({
|
||||||
|
|
@ -1111,11 +1147,7 @@ export class ReportController extends Controller {
|
||||||
const dev10text = "การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)";
|
const dev10text = "การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)";
|
||||||
const dev20text = "การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)";
|
const dev20text = "การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)";
|
||||||
const dev70text = "การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)";
|
const dev70text = "การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)";
|
||||||
const combianText = [
|
const combianText = [dev10text, dev20text, dev70text];
|
||||||
dev10text,
|
|
||||||
dev20text,
|
|
||||||
dev70text
|
|
||||||
];
|
|
||||||
|
|
||||||
formattedUserDevelopmentLists = userDevelopmentLists.map(
|
formattedUserDevelopmentLists = userDevelopmentLists.map(
|
||||||
(development: any, index: number) => ({
|
(development: any, index: number) => ({
|
||||||
|
|
@ -1137,7 +1169,8 @@ export class ReportController extends Controller {
|
||||||
development.isDevelopment20,
|
development.isDevelopment20,
|
||||||
development.isDevelopment70,
|
development.isDevelopment70,
|
||||||
]
|
]
|
||||||
.map((x: any, index) => (x ? combianText[index]:null)).filter((x: any) => x !== null)
|
.map((x: any, index) => (x ? combianText[index] : null))
|
||||||
|
.filter((x: any) => x !== null)
|
||||||
.join("/"),
|
.join("/"),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -1150,12 +1183,12 @@ export class ReportController extends Controller {
|
||||||
userInfo[0]?.org,
|
userInfo[0]?.org,
|
||||||
];
|
];
|
||||||
affiliation = fullNameParts
|
affiliation = fullNameParts
|
||||||
.filter((part:any) => part !== undefined && part !== null)
|
.filter((part: any) => part !== undefined && part !== null)
|
||||||
.join("/");
|
.join("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formattedData = {
|
formattedData = {
|
||||||
year: period_ ? Extension.ToThaiNumber((period_.year+543).toString()) : "-",
|
year: period_ ? Extension.ToThaiNumber((period_.year + 543).toString()) : "-",
|
||||||
fullName: userInfo
|
fullName: userInfo
|
||||||
? userInfo[0]?.prefix + userInfo[0]?.firstName + " " + userInfo[0]?.lastName
|
? userInfo[0]?.prefix + userInfo[0]?.firstName + " " + userInfo[0]?.lastName
|
||||||
: "-",
|
: "-",
|
||||||
|
|
@ -1166,26 +1199,29 @@ export class ReportController extends Controller {
|
||||||
posLevel: userInfo ? userInfo[0]?.posLevelName : "-",
|
posLevel: userInfo ? userInfo[0]?.posLevelName : "-",
|
||||||
period1: period1 ? Extension.ToThaiNumber(period1) : "-",
|
period1: period1 ? Extension.ToThaiNumber(period1) : "-",
|
||||||
period2: period2 ? Extension.ToThaiNumber(period2) : "-",
|
period2: period2 ? Extension.ToThaiNumber(period2) : "-",
|
||||||
developments:
|
developments: formattedUserDevelopmentLists ? formattedUserDevelopmentLists : [{}],
|
||||||
formattedUserDevelopmentLists ? formattedUserDevelopmentLists : [{}],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (requestBody.type == "KPI9") {
|
if (requestBody.type == "KPI9") {
|
||||||
templateName = "KPI9";
|
templateName = "KPI9";
|
||||||
reportName = "KPI9";
|
reportName = "KPI9";
|
||||||
const userEvaluations_ = data.kpiUserEvaluations.length > 0
|
const userEvaluations_ =
|
||||||
? data.kpiUserEvaluations
|
data.kpiUserEvaluations.length > 0
|
||||||
.filter((x: any) => x.evaluationResults == "EXCELLENT" || x.evaluationResults == "VERY_GOOD")
|
? data.kpiUserEvaluations
|
||||||
.map((x: any, idx: number) => ({
|
.filter(
|
||||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
(x: any) =>
|
||||||
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
x.evaluationResults == "EXCELLENT" || x.evaluationResults == "VERY_GOOD",
|
||||||
position: x.position ? x.position : "",
|
)
|
||||||
posLevelName: x.posLevelName ? x.posLevelName : "",
|
.map((x: any, idx: number) => ({
|
||||||
evaluationResults: x.evaluationResults
|
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||||
? Extension.EvaluationResult(x.evaluationResults)
|
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
||||||
: "",
|
position: x.position ? x.position : "",
|
||||||
}))
|
posLevelName: x.posLevelName ? x.posLevelName : "",
|
||||||
: [{}]
|
evaluationResults: x.evaluationResults
|
||||||
|
? Extension.EvaluationResult(x.evaluationResults)
|
||||||
|
: "",
|
||||||
|
}))
|
||||||
|
: [{}];
|
||||||
formattedData = {
|
formattedData = {
|
||||||
root:
|
root:
|
||||||
data?.kpiUserEvaluations != null && data?.kpiUserEvaluations.length > 0
|
data?.kpiUserEvaluations != null && data?.kpiUserEvaluations.length > 0
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,3 @@
|
||||||
import {
|
|
||||||
Controller,
|
|
||||||
Request,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Delete,
|
|
||||||
Patch,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Path,
|
|
||||||
} from "tsoa";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import CallAPI from "./call-api";
|
import CallAPI from "./call-api";
|
||||||
|
|
@ -26,23 +13,166 @@ class CheckAuth {
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
await new CallAPI()
|
return await new CallAPI()
|
||||||
.GetData(req, "/org/permission")
|
.GetData(req, "/org/permission")
|
||||||
.then((x) => {
|
.then((x) => {
|
||||||
let permission = false;
|
let permission = false;
|
||||||
let role = x.roles.find((x: any) => x.authSysId == system);
|
let role = x.roles.find((x: any) => x.authSysId == system);
|
||||||
if (!role) throw "ไม่มีสิทธิ์เข้าระบบ";
|
if (!role) throw "ไม่มีสิทธิ์เข้าระบบ";
|
||||||
|
if (role.attrOwnership == "OWNER") return "OWNER";
|
||||||
if (action.trim().toLocaleUpperCase() == "CREATE") permission = role.attrIsCreate;
|
if (action.trim().toLocaleUpperCase() == "CREATE") permission = role.attrIsCreate;
|
||||||
if (action.trim().toLocaleUpperCase() == "DELETE") permission = role.attrIsDelete;
|
if (action.trim().toLocaleUpperCase() == "DELETE") permission = role.attrIsDelete;
|
||||||
if (action.trim().toLocaleUpperCase() == "GET") permission = role.attrIsGet;
|
if (action.trim().toLocaleUpperCase() == "GET") permission = role.attrIsGet;
|
||||||
if (action.trim().toLocaleUpperCase() == "LIST") permission = role.attrIsList;
|
if (action.trim().toLocaleUpperCase() == "LIST") permission = role.attrIsList;
|
||||||
if (action.trim().toLocaleUpperCase() == "UPDATE") permission = role.attrIsUpdate;
|
if (action.trim().toLocaleUpperCase() == "UPDATE") permission = role.attrIsUpdate;
|
||||||
if (role.attrOwnership == "OWNER") permission = true;
|
|
||||||
if (permission == false) throw "ไม่มีสิทธิ์ใช้งานระบบนี้";
|
if (permission == false) throw "ไม่มีสิทธิ์ใช้งานระบบนี้";
|
||||||
return role.attrPrivilege;
|
return role.attrPrivilege;
|
||||||
})
|
})
|
||||||
.catch((x) => {
|
.catch((x) => {
|
||||||
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
if (x.status != undefined) {
|
||||||
|
throw new HttpError(x.status, x.message);
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public async PermissionOrg(req: RequestWithUser, system: string, action: string) {
|
||||||
|
if (
|
||||||
|
req.headers.hasOwnProperty("api_key") &&
|
||||||
|
req.headers["api_key"] &&
|
||||||
|
req.headers["api_key"] == process.env.API_KEY
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return await new CallAPI()
|
||||||
|
.GetData(req, "/org/permission/org")
|
||||||
|
.then(async (x) => {
|
||||||
|
let privilege = null;
|
||||||
|
if (action.trim().toLocaleUpperCase() == "CREATE")
|
||||||
|
privilege = await this.PermissionCreate(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "DELETE")
|
||||||
|
privilege = await this.PermissionDelete(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "GET")
|
||||||
|
privilege = await this.PermissionGet(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "LIST")
|
||||||
|
privilege = await this.PermissionList(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "UPDATE")
|
||||||
|
privilege = await this.PermissionUpdate(req, system);
|
||||||
|
|
||||||
|
let data: any = {
|
||||||
|
root: [null],
|
||||||
|
child1: [null],
|
||||||
|
child2: [null],
|
||||||
|
child3: [null],
|
||||||
|
child4: [null],
|
||||||
|
};
|
||||||
|
let node = 4;
|
||||||
|
if (x.orgChild1Id == null) {
|
||||||
|
node = 0;
|
||||||
|
} else if (x.orgChild2Id == null) {
|
||||||
|
node = 1;
|
||||||
|
} else if (x.orgChild3Id == null) {
|
||||||
|
node = 2;
|
||||||
|
} else if (x.orgChild4Id == null) {
|
||||||
|
node = 3;
|
||||||
|
}
|
||||||
|
if (privilege == "ROOT") {
|
||||||
|
data = {
|
||||||
|
root: [x.orgRootId],
|
||||||
|
child1: null,
|
||||||
|
child2: null,
|
||||||
|
child3: null,
|
||||||
|
child4: null,
|
||||||
|
};
|
||||||
|
} else if (privilege == "CHILD") {
|
||||||
|
data = {
|
||||||
|
root: node >= 0 ? [x.orgRootId] : null,
|
||||||
|
child1: node >= 1 ? [x.orgChild1Id] : null,
|
||||||
|
child2: node >= 2 ? [x.orgChild2Id] : null,
|
||||||
|
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||||
|
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||||
|
};
|
||||||
|
} else if (privilege == "NORMAL") {
|
||||||
|
data = {
|
||||||
|
root: [x.orgRootId],
|
||||||
|
child1: [x.orgChild1Id],
|
||||||
|
child2: [x.orgChild2Id],
|
||||||
|
child3: [x.orgChild3Id],
|
||||||
|
child4: [x.orgChild4Id],
|
||||||
|
};
|
||||||
|
} else if (privilege == "SPECIFIC") {
|
||||||
|
} else if (privilege == "OWNER") {
|
||||||
|
data = {
|
||||||
|
root: null,
|
||||||
|
child1: null,
|
||||||
|
child2: null,
|
||||||
|
child3: null,
|
||||||
|
child4: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
})
|
||||||
|
.catch((x) => {
|
||||||
|
if (x.status != undefined) {
|
||||||
|
throw new HttpError(x.status, x.message);
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public async PermissionOrgByUser(
|
||||||
|
req: RequestWithUser,
|
||||||
|
system: string,
|
||||||
|
action: string,
|
||||||
|
profileId: string,
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
req.headers.hasOwnProperty("api_key") &&
|
||||||
|
req.headers["api_key"] &&
|
||||||
|
req.headers["api_key"] == process.env.API_KEY
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return await new CallAPI()
|
||||||
|
.GetData(req, `/org/permission/user/${profileId}`)
|
||||||
|
.then(async (x) => {
|
||||||
|
let org = {
|
||||||
|
root: [null],
|
||||||
|
child1: [null],
|
||||||
|
child2: [null],
|
||||||
|
child3: [null],
|
||||||
|
child4: [null],
|
||||||
|
};
|
||||||
|
if (action.trim().toLocaleUpperCase() == "CREATE")
|
||||||
|
org = await this.PermissionOrgCreate(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "DELETE")
|
||||||
|
org = await this.PermissionOrgDelete(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "GET")
|
||||||
|
org = await this.PermissionOrgGet(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "LIST")
|
||||||
|
org = await this.PermissionOrgList(req, system);
|
||||||
|
if (action.trim().toLocaleUpperCase() == "UPDATE")
|
||||||
|
org = await this.PermissionOrgUpdate(req, system);
|
||||||
|
|
||||||
|
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
|
if (org.child1 != null)
|
||||||
|
if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
|
if (org.child2 != null)
|
||||||
|
if (x.orgChild2Id != org.child2[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
|
if (org.child3 != null)
|
||||||
|
if (x.orgChild3Id != org.child3[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
|
if (org.child4 != null)
|
||||||
|
if (x.orgChild4Id != org.child4[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((x) => {
|
||||||
|
if (x.status != undefined) {
|
||||||
|
throw new HttpError(x.status, x.message);
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||||
|
|
@ -60,6 +190,38 @@ class CheckAuth {
|
||||||
public async PermissionUpdate(req: RequestWithUser, system: string) {
|
public async PermissionUpdate(req: RequestWithUser, system: string) {
|
||||||
return await this.Permission(req, system, "UPDATE");
|
return await this.Permission(req, system, "UPDATE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async PermissionOrgCreate(req: RequestWithUser, system: string) {
|
||||||
|
return await this.PermissionOrg(req, system, "CREATE");
|
||||||
|
}
|
||||||
|
public async PermissionOrgDelete(req: RequestWithUser, system: string) {
|
||||||
|
return await this.PermissionOrg(req, system, "DELETE");
|
||||||
|
}
|
||||||
|
public async PermissionOrgGet(req: RequestWithUser, system: string) {
|
||||||
|
return await this.PermissionOrg(req, system, "GET");
|
||||||
|
}
|
||||||
|
public async PermissionOrgList(req: RequestWithUser, system: string) {
|
||||||
|
return await this.PermissionOrg(req, system, "LIST");
|
||||||
|
}
|
||||||
|
public async PermissionOrgUpdate(req: RequestWithUser, system: string) {
|
||||||
|
return await this.PermissionOrg(req, system, "UPDATE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async PermissionOrgUserCreate(req: RequestWithUser, system: string, profileId: string) {
|
||||||
|
return await this.PermissionOrgByUser(req, system, "CREATE", profileId);
|
||||||
|
}
|
||||||
|
public async PermissionOrgUserDelete(req: RequestWithUser, system: string, profileId: string) {
|
||||||
|
return await this.PermissionOrgByUser(req, system, "DELETE", profileId);
|
||||||
|
}
|
||||||
|
public async PermissionOrgUserGet(req: RequestWithUser, system: string, profileId: string) {
|
||||||
|
return await this.PermissionOrgByUser(req, system, "GET", profileId);
|
||||||
|
}
|
||||||
|
public async PermissionOrgUserList(req: RequestWithUser, system: string, profileId: string) {
|
||||||
|
return await this.PermissionOrgByUser(req, system, "LIST", profileId);
|
||||||
|
}
|
||||||
|
public async PermissionOrgUserUpdate(req: RequestWithUser, system: string, profileId: string) {
|
||||||
|
return await this.PermissionOrgByUser(req, system, "UPDATE", profileId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CheckAuth;
|
export default CheckAuth;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue