fix
This commit is contained in:
parent
57ef58bdb3
commit
2467b28e1f
1 changed files with 194 additions and 43 deletions
|
|
@ -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";
|
||||||
|
|
@ -39,6 +37,7 @@ import { KpiLink } from "../entities/kpiLink";
|
||||||
import { KpiGroup } from "../entities/kpiGroup";
|
import { KpiGroup } from "../entities/kpiGroup";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
|
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||||
|
|
||||||
@Route("api/v1/kpi/user/evaluation")
|
@Route("api/v1/kpi/user/evaluation")
|
||||||
@Tags("kpiUserEvaluation")
|
@Tags("kpiUserEvaluation")
|
||||||
|
|
@ -64,7 +63,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("admin")
|
@Post("admin")
|
||||||
async listKpiAdminEvaluation(
|
async listKpiAdminEvaluation(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
page: number;
|
page: number;
|
||||||
|
|
@ -216,6 +215,123 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionDelete(request, "SYS_RESULT");
|
await new permission().PermissionDelete(request, "SYS_RESULT");
|
||||||
|
let conditionFullName =
|
||||||
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
|
.andWhere(requestBody.kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||||
|
kpiPeriodId: requestBody.kpiPeriodId,
|
||||||
|
})
|
||||||
|
.andWhere(
|
||||||
|
requestBody.status != null && requestBody.status != undefined
|
||||||
|
? "evaluationstatus LIKE :status"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
status:
|
||||||
|
requestBody.status == null || requestBody.status == undefined
|
||||||
|
? null
|
||||||
|
: requestBody.status.trim().toUpperCase(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
requestBody.results != null && requestBody.results != undefined
|
||||||
|
? "evaluationResults LIKE :results"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
results:
|
||||||
|
requestBody.results == null || requestBody.results == undefined
|
||||||
|
? null
|
||||||
|
: requestBody.results.trim().toUpperCase(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere(conditionFullName, {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
|
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||||
|
.take(requestBody.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
const mapData = kpiUserEvaluation.map((item) => {
|
||||||
|
const fullNameParts = [item.child4, item.child3, item.child2, item.child1, item.org];
|
||||||
|
|
||||||
|
const organization = fullNameParts
|
||||||
|
.filter((part) => part !== undefined && part !== null)
|
||||||
|
.join("/");
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
profileId: item.profileId,
|
||||||
|
prefix: item.prefix,
|
||||||
|
firstname: item.firstName,
|
||||||
|
lastname: item.lastName,
|
||||||
|
kpiPeriodId: item.kpiPeriodId,
|
||||||
|
evaluationStatus: item.evaluationStatus,
|
||||||
|
evaluationResults: item.evaluationResults,
|
||||||
|
createdAt: item.createdAt,
|
||||||
|
evaluatorId: item.evaluatorId,
|
||||||
|
commanderId: item.commanderId,
|
||||||
|
commanderHighId: item.commanderHighId,
|
||||||
|
root: item.org ? item.org : null,
|
||||||
|
rootId: item.orgId ? item.orgId : null,
|
||||||
|
position: item.position ? item.position : null,
|
||||||
|
// posTypeId: item.posTypeId,
|
||||||
|
posTypeName: item.posTypeName ? item.posTypeName : null,
|
||||||
|
// posLevelId: item.posLevelId,
|
||||||
|
posLevelName: item.posLevelName ? item.posLevelName : null,
|
||||||
|
organization: organization ? organization : null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return new HttpSuccess({ data: mapData, total });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API
|
||||||
|
*
|
||||||
|
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("list")
|
||||||
|
async listKpiListEvaluation(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
kpiPeriodId?: string;
|
||||||
|
keyword?: string;
|
||||||
|
status?: string | null;
|
||||||
|
results?: string | null;
|
||||||
|
reqedit?: string | null;
|
||||||
|
evaluating?: boolean | null;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
await new permission().PermissionDelete(request, "SYS_KPI_LIST");
|
||||||
let conditionFullName =
|
let conditionFullName =
|
||||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
|
|
@ -401,13 +517,15 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
kpiUserEvaluation.posTypeNameEvaluator = x.posTypeName;
|
kpiUserEvaluation.posTypeNameEvaluator = x.posTypeName;
|
||||||
kpiUserEvaluation.orgEvaluator = x.root;
|
kpiUserEvaluation.orgEvaluator = x.root;
|
||||||
});
|
});
|
||||||
|
const before = null;
|
||||||
kpiUserEvaluation.evaluationStatus = "NEW";
|
kpiUserEvaluation.evaluationStatus = "NEW";
|
||||||
kpiUserEvaluation.evaluationResults = "PENDING";
|
kpiUserEvaluation.evaluationResults = "PENDING";
|
||||||
kpiUserEvaluation.createdUserId = request.user.sub;
|
kpiUserEvaluation.createdUserId = request.user.sub;
|
||||||
kpiUserEvaluation.createdFullName = request.user.name;
|
kpiUserEvaluation.createdFullName = request.user.name;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
enum CapacityType {
|
enum CapacityType {
|
||||||
HEAD = "HEAD",
|
HEAD = "HEAD",
|
||||||
|
|
@ -533,7 +651,9 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
kpiUserEvaluation.weightPoint1 = 50;
|
kpiUserEvaluation.weightPoint1 = 50;
|
||||||
kpiUserEvaluation.weightPoint2 = 50;
|
kpiUserEvaluation.weightPoint2 = 50;
|
||||||
}
|
}
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
|
||||||
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
@ -549,7 +669,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserCheckEvaluation(
|
async updateKpiUserCheckEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserCheckEvaluation,
|
@Body() requestBody: updateKpiUserCheckEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -560,10 +680,14 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
|
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
Object.assign(kpiUserEvaluation, requestBody);
|
Object.assign(kpiUserEvaluation, requestBody);
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -578,7 +702,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserPointEvaluation(
|
async updateKpiUserPointEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserPointEvaluation,
|
@Body() requestBody: updateKpiUserPointEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -605,10 +729,12 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
} else {
|
} else {
|
||||||
kpiUserEvaluation.evaluationResults = "IMPROVEMENT";
|
kpiUserEvaluation.evaluationResults = "IMPROVEMENT";
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
Object.assign(kpiUserEvaluation, requestBody);
|
Object.assign(kpiUserEvaluation, requestBody);
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,7 +749,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserEvaluation(
|
async updateKpiUserEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserEvaluation,
|
@Body() requestBody: updateKpiUserEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -644,11 +770,12 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
Object.assign(kpiUserEvaluation, requestBody);
|
Object.assign(kpiUserEvaluation, requestBody);
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -663,7 +790,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserReqEditEvaluation(
|
async updateKpiUserReqEditEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserReqEditEvaluation,
|
@Body() requestBody: updateKpiUserReqEditEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -674,10 +801,12 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
kpiUserEvaluation.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -692,7 +821,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserResultEvaluation(
|
async updateKpiUserResultEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserResultEvaluation,
|
@Body() requestBody: updateKpiUserResultEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -703,10 +832,12 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.evaluationResults = requestBody.status.trim().toUpperCase();
|
kpiUserEvaluation.evaluationResults = requestBody.status.trim().toUpperCase();
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -721,7 +852,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async updateKpiUserStatusEvaluation(
|
async updateKpiUserStatusEvaluation(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() requestBody: updateKpiUserStatusEvaluation,
|
@Body() requestBody: updateKpiUserStatusEvaluation,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -759,10 +890,12 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
.then((x) => {})
|
.then((x) => {})
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.evaluationStatus = requestBody.status.trim().toUpperCase();
|
kpiUserEvaluation.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,7 +1027,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiUserEvaluation(@Path() id: string) {
|
async deleteKpiUserEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -904,7 +1037,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.kpiUserEvalutionRepository.remove(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.remove(kpiUserEvaluation, { data: request });
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -917,7 +1050,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("admin/change-status")
|
@Post("admin/change-status")
|
||||||
async ChangeStatus(
|
async ChangeStatus(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
status: string;
|
status: string;
|
||||||
|
|
@ -1001,9 +1134,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
} else {
|
} else {
|
||||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
item.lastUpdateUserId = request.user.sub;
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.lastUpdateFullName = request.user.name;
|
item.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(item);
|
await this.kpiUserEvalutionRepository.save(item, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: item });
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -1018,7 +1153,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("admin/req-edit")
|
@Post("admin/req-edit")
|
||||||
async RequestEdit(
|
async RequestEdit(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
status: string;
|
status: string;
|
||||||
|
|
@ -1082,9 +1217,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
item.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
item.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const before = null;
|
||||||
item.lastUpdateUserId = request.user.sub;
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.lastUpdateFullName = request.user.name;
|
item.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(item);
|
await this.kpiUserEvalutionRepository.save(item, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: item });
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -1099,7 +1236,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("admin/result-status")
|
@Post("admin/result-status")
|
||||||
async ResultStatus(
|
async ResultStatus(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
status: string;
|
status: string;
|
||||||
|
|
@ -1160,9 +1297,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
// } else {
|
// } else {
|
||||||
// // item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
// // item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
// }
|
// }
|
||||||
|
const before = null;
|
||||||
item.lastUpdateUserId = request.user.sub;
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.lastUpdateFullName = request.user.name;
|
item.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(item);
|
await this.kpiUserEvalutionRepository.save(item, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: item });
|
||||||
});
|
});
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -1174,10 +1313,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||||
*/
|
*/
|
||||||
@Get("open/{id}")
|
@Get("open/{id}")
|
||||||
async openKpiUserEvaluation(
|
async openKpiUserEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
@Path() id: string,
|
|
||||||
@Request() request: { user: Record<string, any> },
|
|
||||||
) {
|
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
@ -1187,11 +1323,13 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.isOpen = true;
|
kpiUserEvaluation.isOpen = true;
|
||||||
kpiUserEvaluation.openDate = new Date();
|
kpiUserEvaluation.openDate = new Date();
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1212,7 +1350,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
timeEvaluator?: string | null;
|
timeEvaluator?: string | null;
|
||||||
reasonEvaluator?: string | null;
|
reasonEvaluator?: string | null;
|
||||||
},
|
},
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -1253,6 +1391,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER";
|
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER";
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
|
|
||||||
kpiUserEvaluation.topicEvaluator =
|
kpiUserEvaluation.topicEvaluator =
|
||||||
requestBody.topicEvaluator == null ? _null : requestBody.topicEvaluator;
|
requestBody.topicEvaluator == null ? _null : requestBody.topicEvaluator;
|
||||||
kpiUserEvaluation.developEvaluator =
|
kpiUserEvaluation.developEvaluator =
|
||||||
|
|
@ -1263,7 +1403,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
requestBody.reasonEvaluator == null ? _null : requestBody.reasonEvaluator;
|
requestBody.reasonEvaluator == null ? _null : requestBody.reasonEvaluator;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1282,7 +1423,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
isReason: boolean;
|
isReason: boolean;
|
||||||
reason?: string | null;
|
reason?: string | null;
|
||||||
},
|
},
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -1323,11 +1464,15 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH";
|
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH";
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
|
|
||||||
kpiUserEvaluation.isReasonCommander = requestBody.isReason;
|
kpiUserEvaluation.isReasonCommander = requestBody.isReason;
|
||||||
kpiUserEvaluation.reasonCommander = requestBody.reason == null ? _null : requestBody.reason;
|
kpiUserEvaluation.reasonCommander = requestBody.reason == null ? _null : requestBody.reason;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1346,7 +1491,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
isReason: boolean;
|
isReason: boolean;
|
||||||
reason?: string | null;
|
reason?: string | null;
|
||||||
},
|
},
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -1371,11 +1516,15 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
})
|
})
|
||||||
.then((x) => {})
|
.then((x) => {})
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
|
|
||||||
kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason;
|
kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason;
|
||||||
kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason;
|
kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
return new HttpSuccess(kpiUserEvaluation.id);
|
return new HttpSuccess(kpiUserEvaluation.id);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -1426,9 +1575,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
})
|
})
|
||||||
.then((x) => {})
|
.then((x) => {})
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
|
const before = null;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1495,10 +1646,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||||
*/
|
*/
|
||||||
@Get("summary/{id}")
|
@Get("summary/{id}")
|
||||||
async getSummaryKpiEvaluation(
|
async getSummaryKpiEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
@Path() id: string,
|
|
||||||
@Request() request: { user: Record<string, any> },
|
|
||||||
) {
|
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["id", "evaluationStatus", "lastUpdateUserId", "lastUpdateFullName"],
|
select: ["id", "evaluationStatus", "lastUpdateUserId", "lastUpdateFullName"],
|
||||||
|
|
@ -1509,10 +1657,13 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
kpiUserEvaluation.evaluationStatus = "SUMMARY";
|
kpiUserEvaluation.evaluationStatus = "SUMMARY";
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: kpiUserEvaluation });
|
||||||
|
|
||||||
return new HttpSuccess(kpiUserEvaluation);
|
return new HttpSuccess(kpiUserEvaluation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue