Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-09-06 14:14:20 +07:00
commit d7eef65555
18 changed files with 507 additions and 374 deletions

View file

@ -25,7 +25,7 @@ import { KpiCapacityDetail } from "../entities/kpiCapacityDetail";
import { Like, In } from "typeorm"; import { Like, In } from "typeorm";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/capacity") @Route("api/v1/kpi/capacity")
@Tags("kpiCapacity") @Tags("kpiCapacity")
@ -83,6 +83,8 @@ export class kpiCapacityController extends Controller {
kpiCapacity.createdFullName = request.user.name; kpiCapacity.createdFullName = request.user.name;
kpiCapacity.lastUpdateUserId = request.user.sub; kpiCapacity.lastUpdateUserId = request.user.sub;
kpiCapacity.lastUpdateFullName = request.user.name; kpiCapacity.lastUpdateFullName = request.user.name;
kpiCapacity.createdAt = new Date();
kpiCapacity.lastUpdatedAt = new Date();
await this.kpiCapacityRepository.save(kpiCapacity, { data: request }); await this.kpiCapacityRepository.save(kpiCapacity, { data: request });
setLogDataDiff(request, { before, after: kpiCapacity }); setLogDataDiff(request, { before, after: kpiCapacity });
@ -100,6 +102,8 @@ export class kpiCapacityController extends Controller {
kpiCapacityDetail.createdFullName = request.user.name; kpiCapacityDetail.createdFullName = request.user.name;
kpiCapacityDetail.lastUpdateUserId = request.user.sub; kpiCapacityDetail.lastUpdateUserId = request.user.sub;
kpiCapacityDetail.lastUpdateFullName = request.user.name; kpiCapacityDetail.lastUpdateFullName = request.user.name;
kpiCapacityDetail.createdAt = new Date();
kpiCapacityDetail.lastUpdatedAt = new Date();
await this.kpiCapacityDetailRepository.save(kpiCapacityDetail, { data: request }); await this.kpiCapacityDetailRepository.save(kpiCapacityDetail, { data: request });
setLogDataDiff(request, { before, after: kpiCapacityDetail }); setLogDataDiff(request, { before, after: kpiCapacityDetail });
} }
@ -155,6 +159,7 @@ export class kpiCapacityController extends Controller {
const before = structuredClone(kpiCapacity); const before = structuredClone(kpiCapacity);
kpiCapacity.lastUpdateUserId = request.user.sub; kpiCapacity.lastUpdateUserId = request.user.sub;
kpiCapacity.lastUpdateFullName = request.user.name; kpiCapacity.lastUpdateFullName = request.user.name;
kpiCapacity.lastUpdatedAt = new Date();
this.kpiCapacityRepository.merge(kpiCapacity, _kpiCapacity); this.kpiCapacityRepository.merge(kpiCapacity, _kpiCapacity);
await this.kpiCapacityRepository.save(kpiCapacity, { data: request }); await this.kpiCapacityRepository.save(kpiCapacity, { data: request });
setLogDataDiff(request, { before, after: kpiCapacity }); setLogDataDiff(request, { before, after: kpiCapacity });
@ -180,6 +185,8 @@ export class kpiCapacityController extends Controller {
kpiCapacityDetail.createdFullName = request.user.name; kpiCapacityDetail.createdFullName = request.user.name;
kpiCapacityDetail.lastUpdateUserId = request.user.sub; kpiCapacityDetail.lastUpdateUserId = request.user.sub;
kpiCapacityDetail.lastUpdateFullName = request.user.name; kpiCapacityDetail.lastUpdateFullName = request.user.name;
kpiCapacityDetail.createdAt = new Date();
kpiCapacityDetail.lastUpdatedAt = new Date();
await this.kpiCapacityDetailRepository.save(kpiCapacityDetail, { data: request }); await this.kpiCapacityDetailRepository.save(kpiCapacityDetail, { data: request });
setLogDataDiff(request, { before: beforeDetail, after: kpiCapacityDetail }); setLogDataDiff(request, { before: beforeDetail, after: kpiCapacityDetail });
} }

View file

@ -19,7 +19,7 @@ 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";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/evaluation") @Route("api/v1/kpi/evaluation")
@Tags("kpiEvaluation") @Tags("kpiEvaluation")
@ -56,6 +56,7 @@ export class kpiEvaluationController extends Controller {
this.kpiEvaluationRepository.merge(kpiEvaluation, item); this.kpiEvaluationRepository.merge(kpiEvaluation, item);
kpiEvaluation.lastUpdateUserId = request.user.sub; kpiEvaluation.lastUpdateUserId = request.user.sub;
kpiEvaluation.lastUpdateFullName = request.user.name; kpiEvaluation.lastUpdateFullName = request.user.name;
kpiEvaluation.lastUpdatedAt = new Date();
await this.kpiEvaluationRepository.save(kpiEvaluation, { data: request }); await this.kpiEvaluationRepository.save(kpiEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiEvaluation }); setLogDataDiff(request, { before, after: kpiEvaluation });

View file

@ -23,7 +23,7 @@ import HttpStatusCode from "../interfaces/http-status";
import { KpiGroup, createKpiGroup, updateKpiGroup } from "../entities/kpiGroup"; import { KpiGroup, createKpiGroup, updateKpiGroup } from "../entities/kpiGroup";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/group") @Route("api/v1/kpi/group")
@Tags("kpiGroup") @Tags("kpiGroup")
@ -62,6 +62,8 @@ export class kpiGroupController extends Controller {
kpiGroup.createdFullName = request.user.name; kpiGroup.createdFullName = request.user.name;
kpiGroup.lastUpdateUserId = request.user.sub; kpiGroup.lastUpdateUserId = request.user.sub;
kpiGroup.lastUpdateFullName = request.user.name; kpiGroup.lastUpdateFullName = request.user.name;
kpiGroup.createdAt = new Date();
kpiGroup.lastUpdatedAt = new Date();
await this.kpiGroupRepository.save(kpiGroup, { data: request }); await this.kpiGroupRepository.save(kpiGroup, { data: request });
setLogDataDiff(request, { before, after: kpiGroup }); setLogDataDiff(request, { before, after: kpiGroup });
@ -100,6 +102,7 @@ export class kpiGroupController extends Controller {
this.kpiGroupRepository.merge(kpiGroup, requestBody); this.kpiGroupRepository.merge(kpiGroup, requestBody);
kpiGroup.lastUpdateUserId = request.user.sub; kpiGroup.lastUpdateUserId = request.user.sub;
kpiGroup.lastUpdateFullName = request.user.name; kpiGroup.lastUpdateFullName = request.user.name;
kpiGroup.lastUpdatedAt = new Date();
await this.kpiGroupRepository.save(kpiGroup, { data: request }); await this.kpiGroupRepository.save(kpiGroup, { data: request });
setLogDataDiff(request, { before, after: kpiGroup }); setLogDataDiff(request, { before, after: kpiGroup });

View file

@ -25,7 +25,7 @@ import { KpiCapacity } from "../entities/kpiCapacity";
import { Position } from "../entities/position"; import { Position } from "../entities/position";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/link") @Route("api/v1/kpi/link")
@Tags("kpiLink") @Tags("kpiLink")
@ -65,6 +65,8 @@ export class kpiLinkController extends Controller {
createdFullName: request.user.name, createdFullName: request.user.name,
lastUpdateUserId: request.user.sub, lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name, lastUpdateFullName: request.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
kpiGroup: chkkpiGroup, kpiGroup: chkkpiGroup,
}); });
await this.kpiLinkRepository.save(kpiLink, { data: request }); await this.kpiLinkRepository.save(kpiLink, { data: request });
@ -80,6 +82,8 @@ export class kpiLinkController extends Controller {
position.createdFullName = request.user.name; position.createdFullName = request.user.name;
position.lastUpdateUserId = request.user.sub; position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name; position.lastUpdateFullName = request.user.name;
position.createdAt = new Date();
position.lastUpdatedAt = new Date();
await this.positionRepository.save(position, { data: request }); await this.positionRepository.save(position, { data: request });
setLogDataDiff(request, { before, after: position }); setLogDataDiff(request, { before, after: position });
}), }),
@ -132,9 +136,10 @@ export class kpiLinkController extends Controller {
...requestBody, ...requestBody,
kpiCapacitys: [], kpiCapacitys: [],
}); });
(chkKpiLink.kpiGroupId = requestBody.kpiGroupId), chkKpiLink.kpiGroupId = requestBody.kpiGroupId;
(chkKpiLink.lastUpdateUserId = request.user.sub); chkKpiLink.lastUpdateUserId = request.user.sub;
chkKpiLink.lastUpdateFullName = request.user.name; chkKpiLink.lastUpdateFullName = request.user.name;
chkKpiLink.lastUpdatedAt = new Date();
if (requestBody.positions != null) { if (requestBody.positions != null) {
await Promise.all( await Promise.all(
@ -146,6 +151,8 @@ export class kpiLinkController extends Controller {
position.createdFullName = request.user.name; position.createdFullName = request.user.name;
position.lastUpdateUserId = request.user.sub; position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name; position.lastUpdateFullName = request.user.name;
position.createdAt = new Date();
position.lastUpdatedAt = new Date();
await this.positionRepository.save(position, { data: request }); await this.positionRepository.save(position, { data: request });
setLogDataDiff(request, { before: null, after: position }); setLogDataDiff(request, { before: null, after: position });
}), }),
@ -323,6 +330,9 @@ export class kpiLinkController extends Controller {
} }
kpiLink.kpiCapacitys = []; kpiLink.kpiCapacitys = [];
kpiLink.lastUpdateUserId = request.user.sub;
kpiLink.lastUpdateFullName = request.user.name;
kpiLink.lastUpdatedAt = new Date();
await this.kpiLinkRepository.save(kpiLink, { data: request }); await this.kpiLinkRepository.save(kpiLink, { data: request });
await this.positionRepository.delete({ kpiLinkId: id }); await this.positionRepository.delete({ kpiLinkId: id });

View file

@ -30,7 +30,7 @@ import { KpiUserCapacity } from "../entities/kpiUserCapacity";
import { KpiUserSpecial } from "../entities/kpiUserSpecial"; import { KpiUserSpecial } from "../entities/kpiUserSpecial";
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"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/period") @Route("api/v1/kpi/period")
@Tags("kpiPeriod") @Tags("kpiPeriod")
@ -78,6 +78,8 @@ export class kpiPeriodController extends Controller {
kpiPeriod.createdFullName = request.user.name; kpiPeriod.createdFullName = request.user.name;
kpiPeriod.lastUpdateUserId = request.user.sub; kpiPeriod.lastUpdateUserId = request.user.sub;
kpiPeriod.lastUpdateFullName = request.user.name; kpiPeriod.lastUpdateFullName = request.user.name;
kpiPeriod.createdAt = new Date();
kpiPeriod.lastUpdatedAt = new Date();
await this.kpiPeriodRepository.save(kpiPeriod, { data: request }); await this.kpiPeriodRepository.save(kpiPeriod, { data: request });
setLogDataDiff(request, { before, after: kpiPeriod }); setLogDataDiff(request, { before, after: kpiPeriod });
@ -120,10 +122,9 @@ export class kpiPeriodController extends Controller {
requestBody.durationKPI = requestBody.durationKPI.trim().toUpperCase(); requestBody.durationKPI = requestBody.durationKPI.trim().toUpperCase();
this.kpiPeriodRepository.merge(kpiPeriod, requestBody); this.kpiPeriodRepository.merge(kpiPeriod, requestBody);
kpiPeriod.createdUserId = request.user.sub;
kpiPeriod.createdFullName = request.user.name;
kpiPeriod.lastUpdateUserId = request.user.sub; kpiPeriod.lastUpdateUserId = request.user.sub;
kpiPeriod.lastUpdateFullName = request.user.name; kpiPeriod.lastUpdateFullName = request.user.name;
kpiPeriod.lastUpdatedAt = new Date();
await this.kpiPeriodRepository.save(kpiPeriod, { data: request }); await this.kpiPeriodRepository.save(kpiPeriod, { data: request });
setLogDataDiff(request, { before, after: kpiPeriod }); setLogDataDiff(request, { before, after: kpiPeriod });
@ -154,6 +155,9 @@ export class kpiPeriodController extends Controller {
const before = structuredClone(kpiPeriod); const before = structuredClone(kpiPeriod);
kpiPeriod.isActive = false; kpiPeriod.isActive = false;
kpiPeriod.lastUpdateUserId = request.user.sub;
kpiPeriod.lastUpdateFullName = request.user.name;
kpiPeriod.lastUpdatedAt = new Date();
await this.kpiPeriodRepository.save(kpiPeriod, { data: request }); await this.kpiPeriodRepository.save(kpiPeriod, { data: request });
setLogDataDiff(request, { before, after: kpiPeriod }); setLogDataDiff(request, { before, after: kpiPeriod });
@ -184,6 +188,9 @@ export class kpiPeriodController extends Controller {
const before = structuredClone(kpiPeriod); const before = structuredClone(kpiPeriod);
kpiPeriod.isActive = true; kpiPeriod.isActive = true;
kpiPeriod.lastUpdateUserId = request.user.sub;
kpiPeriod.lastUpdateFullName = request.user.name;
kpiPeriod.lastUpdatedAt = new Date();
await this.kpiPeriodRepository.save(kpiPeriod, { data: request }); await this.kpiPeriodRepository.save(kpiPeriod, { data: request });
setLogDataDiff(request, { before, after: kpiPeriod }); setLogDataDiff(request, { before, after: kpiPeriod });

View file

@ -26,7 +26,7 @@ import { KpiSpecial } from "../entities/kpiSpecial";
import { KpiRole } from "../entities/kpiRole"; import { KpiRole } from "../entities/kpiRole";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/plan") @Route("api/v1/kpi/plan")
@Tags("kpiPlan") @Tags("kpiPlan")
@ -186,6 +186,8 @@ export class kpiPlanController extends Controller {
kpiPlan.createdFullName = request.user.name; kpiPlan.createdFullName = request.user.name;
kpiPlan.lastUpdateUserId = request.user.sub; kpiPlan.lastUpdateUserId = request.user.sub;
kpiPlan.lastUpdateFullName = request.user.name; kpiPlan.lastUpdateFullName = request.user.name;
kpiPlan.createdAt = new Date();
kpiPlan.lastUpdatedAt = new Date();
await this.kpiPlanRepository.save(kpiPlan, { data: request }); await this.kpiPlanRepository.save(kpiPlan, { data: request });
setLogDataDiff(request, { before, after: kpiPlan }); setLogDataDiff(request, { before, after: kpiPlan });
@ -195,6 +197,8 @@ export class kpiPlanController extends Controller {
history.createdFullName = request.user.name; history.createdFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name; history.lastUpdateFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await this.kpiPlanHistoryRepository.save(history, { data: request }); await this.kpiPlanHistoryRepository.save(history, { data: request });
setLogDataDiff(request, { before: null, after: history }); setLogDataDiff(request, { before: null, after: history });
@ -280,6 +284,8 @@ export class kpiPlanController extends Controller {
kpiPlan.createdFullName = request.user.name; kpiPlan.createdFullName = request.user.name;
kpiPlan.lastUpdateUserId = request.user.sub; kpiPlan.lastUpdateUserId = request.user.sub;
kpiPlan.lastUpdateFullName = request.user.name; kpiPlan.lastUpdateFullName = request.user.name;
kpiPlan.createdAt = new Date();
kpiPlan.lastUpdatedAt = new Date();
await this.kpiPlanRepository.save(kpiPlan, { data: request }); await this.kpiPlanRepository.save(kpiPlan, { data: request });
setLogDataDiff(request, { before, after: kpiPlan }); setLogDataDiff(request, { before, after: kpiPlan });
@ -290,6 +296,8 @@ export class kpiPlanController extends Controller {
history.createdFullName = request.user.name; history.createdFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name; history.lastUpdateFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await this.kpiPlanHistoryRepository.save(history, { data: request }); await this.kpiPlanHistoryRepository.save(history, { data: request });
setLogDataDiff(request, { before: null, after: history }); setLogDataDiff(request, { before: null, after: history });
@ -803,6 +811,9 @@ export class kpiPlanController extends Controller {
remainingKpiPlans.forEach((kpiPlan: any, index: any) => { remainingKpiPlans.forEach((kpiPlan: any, index: any) => {
kpiPlan.including = index + 1; kpiPlan.including = index + 1;
}); });
remainingKpiPlans.lastUpdateUserId = request.user.sub;
remainingKpiPlans.lastUpdateFullName = request.user.name;
remainingKpiPlans.lastUpdatedAt = new Date();
await this.kpiPlanRepository.save(remainingKpiPlans, { data: request }); await this.kpiPlanRepository.save(remainingKpiPlans, { data: request });
} }

View file

@ -30,7 +30,7 @@ import { KpiUserCapacity } from "../entities/kpiUserCapacity";
import { KpiUserDevelopment } from "../entities/kpiUserDevelopment"; import { KpiUserDevelopment } from "../entities/kpiUserDevelopment";
import { KpiUserPlanned } from "../entities/kpiUserPlanned"; import { KpiUserPlanned } from "../entities/kpiUserPlanned";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/reason") @Route("api/v1/kpi/reason")
@Tags("kpiReason") @Tags("kpiReason")
@ -121,6 +121,8 @@ export class kpiReasonController extends Controller {
kpiUserEvaluationReason.createdFullName = request.user.name; kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub; kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name; kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
kpiUserEvaluationReason.createdAt = new Date();
kpiUserEvaluationReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonPlan.save(kpiUserEvaluationReason, { data: request }); await this.kpiUserEvaluationReasonPlan.save(kpiUserEvaluationReason, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluationReason }); setLogDataDiff(request, { before, after: kpiUserEvaluationReason });
@ -159,6 +161,7 @@ export class kpiReasonController extends Controller {
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonPlan.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonPlan.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -199,6 +202,7 @@ export class kpiReasonController extends Controller {
kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason; kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason;
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonPlan.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonPlan.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -348,6 +352,8 @@ export class kpiReasonController extends Controller {
kpiUserEvaluationReason.createdFullName = request.user.name; kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub; kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name; kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
kpiUserEvaluationReason.createdAt = new Date();
kpiUserEvaluationReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonRole.save(kpiUserEvaluationReason, { data: request }); await this.kpiUserEvaluationReasonRole.save(kpiUserEvaluationReason, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluationReason }); setLogDataDiff(request, { before, after: kpiUserEvaluationReason });
@ -386,6 +392,7 @@ export class kpiReasonController extends Controller {
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonRole.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonRole.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -426,6 +433,7 @@ export class kpiReasonController extends Controller {
kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason; kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason;
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonRole.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonRole.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -578,6 +586,8 @@ export class kpiReasonController extends Controller {
kpiUserEvaluationReason.createdFullName = request.user.name; kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub; kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name; kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
kpiUserEvaluationReason.createdAt = new Date();
kpiUserEvaluationReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonSpecial.save(kpiUserEvaluationReason, { data: request }); await this.kpiUserEvaluationReasonSpecial.save(kpiUserEvaluationReason, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluationReason }); setLogDataDiff(request, { before, after: kpiUserEvaluationReason });
@ -616,6 +626,7 @@ export class kpiReasonController extends Controller {
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonSpecial.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonSpecial.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -656,6 +667,7 @@ export class kpiReasonController extends Controller {
kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason; kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason;
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonSpecial.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonSpecial.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -804,6 +816,8 @@ export class kpiReasonController extends Controller {
kpiUserEvaluationReason.createdFullName = request.user.name; kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub; kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name; kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
kpiUserEvaluationReason.createdAt = new Date();
kpiUserEvaluationReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonDevelopment.save(kpiUserEvaluationReason, { await this.kpiUserEvaluationReasonDevelopment.save(kpiUserEvaluationReason, {
data: request, data: request,
}); });
@ -844,6 +858,7 @@ export class kpiReasonController extends Controller {
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonDevelopment.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonDevelopment.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -884,6 +899,7 @@ export class kpiReasonController extends Controller {
kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason; kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason;
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonDevelopment.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonDevelopment.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -1036,6 +1052,8 @@ export class kpiReasonController extends Controller {
kpiUserEvaluationReason.createdFullName = request.user.name; kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub; kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name; kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
kpiUserEvaluationReason.createdAt = new Date();
kpiUserEvaluationReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonCapacity.save(kpiUserEvaluationReason, { data: request }); await this.kpiUserEvaluationReasonCapacity.save(kpiUserEvaluationReason, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluationReason }); setLogDataDiff(request, { before, after: kpiUserEvaluationReason });
@ -1074,6 +1092,7 @@ export class kpiReasonController extends Controller {
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonCapacity.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonCapacity.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });
@ -1114,6 +1133,7 @@ export class kpiReasonController extends Controller {
kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason; kpiReason.reason = requestBody.reason == null ? "" : requestBody.reason;
kpiReason.lastUpdateUserId = request.user.sub; kpiReason.lastUpdateUserId = request.user.sub;
kpiReason.lastUpdateFullName = request.user.name; kpiReason.lastUpdateFullName = request.user.name;
kpiReason.lastUpdatedAt = new Date();
await this.kpiUserEvaluationReasonCapacity.save(kpiReason, { data: request }); await this.kpiUserEvaluationReasonCapacity.save(kpiReason, { data: request });
setLogDataDiff(request, { before, after: kpiReason }); setLogDataDiff(request, { before, after: kpiReason });

View file

@ -24,8 +24,7 @@ import { Brackets, IsNull, Like } from "typeorm";
import { KpiRoleHistory } from "../entities/kpiRoleHistory"; import { KpiRoleHistory } from "../entities/kpiRoleHistory";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/role") @Route("api/v1/kpi/role")
@Tags("kpiRole") @Tags("kpiRole")
@ -181,6 +180,8 @@ export class kpiRoleController extends Controller {
kpiRole.createdFullName = request.user.name; kpiRole.createdFullName = request.user.name;
kpiRole.lastUpdateUserId = request.user.sub; kpiRole.lastUpdateUserId = request.user.sub;
kpiRole.lastUpdateFullName = request.user.name; kpiRole.lastUpdateFullName = request.user.name;
kpiRole.createdAt = new Date();
kpiRole.lastUpdatedAt = new Date();
await this.kpiRoleRepository.save(kpiRole, { data: request }); await this.kpiRoleRepository.save(kpiRole, { data: request });
setLogDataDiff(request, { before, after: kpiRole }); setLogDataDiff(request, { before, after: kpiRole });
@ -190,6 +191,8 @@ export class kpiRoleController extends Controller {
history.createdFullName = request.user.name; history.createdFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name; history.lastUpdateFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await this.kpiRoleHistoryRepository.save(history, { data: request }); await this.kpiRoleHistoryRepository.save(history, { data: request });
setLogDataDiff(request, { before, after: kpiRole }); setLogDataDiff(request, { before, after: kpiRole });
@ -257,6 +260,8 @@ export class kpiRoleController extends Controller {
kpiRole.createdFullName = request.user.name; kpiRole.createdFullName = request.user.name;
kpiRole.lastUpdateUserId = request.user.sub; kpiRole.lastUpdateUserId = request.user.sub;
kpiRole.lastUpdateFullName = request.user.name; kpiRole.lastUpdateFullName = request.user.name;
kpiRole.createdAt = new Date();
kpiRole.lastUpdatedAt = new Date();
await this.kpiRoleRepository.save(kpiRole, { data: request }); await this.kpiRoleRepository.save(kpiRole, { data: request });
setLogDataDiff(request, { before, after: kpiRole }); setLogDataDiff(request, { before, after: kpiRole });
@ -267,6 +272,8 @@ export class kpiRoleController extends Controller {
history.createdFullName = request.user.name; history.createdFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name; history.lastUpdateFullName = request.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await this.kpiRoleHistoryRepository.save(history, { data: request }); await this.kpiRoleHistoryRepository.save(history, { data: request });
setLogDataDiff(request, { before, after: kpiRole }); setLogDataDiff(request, { before, after: kpiRole });
@ -761,6 +768,9 @@ export class kpiRoleController extends Controller {
remainingKpiRoles.forEach((kpiRole: any, index: any) => { remainingKpiRoles.forEach((kpiRole: any, index: any) => {
kpiRole.including = index + 1; kpiRole.including = index + 1;
}); });
remainingKpiRoles.lastUpdateUserId = request.user.sub;
remainingKpiRoles.lastUpdateFullName = request.user.name;
remainingKpiRoles.lastUpdatedAt = new Date();
await this.kpiRoleRepository.save(remainingKpiRoles, { data: request }); await this.kpiRoleRepository.save(remainingKpiRoles, { data: request });
} }
return new HttpSuccess(); return new HttpSuccess();

View file

@ -21,7 +21,7 @@ import { KpiSpecial, CreateKpiSpecial, UpdateKpiSpecial } from "../entities/kpiS
import { Brackets, Not } from "typeorm"; import { Brackets, Not } from "typeorm";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/special") @Route("api/v1/kpi/special")
@Tags("kpiSpecial") @Tags("kpiSpecial")
@ -67,6 +67,8 @@ export class kpiSpecialController extends Controller {
kpiSpecial.createdFullName = request.user.name; kpiSpecial.createdFullName = request.user.name;
kpiSpecial.lastUpdateUserId = request.user.sub; kpiSpecial.lastUpdateUserId = request.user.sub;
kpiSpecial.lastUpdateFullName = request.user.name; kpiSpecial.lastUpdateFullName = request.user.name;
kpiSpecial.createdAt = new Date();
kpiSpecial.lastUpdatedAt = new Date();
await this.kpiSpecialRepository.save(kpiSpecial, { data: request }); await this.kpiSpecialRepository.save(kpiSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiSpecial }); setLogDataDiff(request, { before, after: kpiSpecial });
@ -110,6 +112,7 @@ export class kpiSpecialController extends Controller {
kpiSpecial.lastUpdateUserId = request.user.sub; kpiSpecial.lastUpdateUserId = request.user.sub;
kpiSpecial.lastUpdateFullName = request.user.name; kpiSpecial.lastUpdateFullName = request.user.name;
kpiSpecial.lastUpdatedAt = new Date();
Object.assign(kpiSpecial, requestBody); Object.assign(kpiSpecial, requestBody);
await this.kpiSpecialRepository.save(kpiSpecial, { data: request }); await this.kpiSpecialRepository.save(kpiSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiSpecial }); setLogDataDiff(request, { before, after: kpiSpecial });

View file

@ -23,9 +23,7 @@ import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
import { KpiUserCapacity, KpiUserCapacityDataPoint } from "../entities/kpiUserCapacity"; import { KpiUserCapacity, KpiUserCapacityDataPoint } from "../entities/kpiUserCapacity";
import { Not } from "typeorm"; import { Not } from "typeorm";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission"; import { setLogDataDiff } from "../interfaces/utils";
import { request } from "axios";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/capacity") @Route("api/v1/kpi/user/capacity")
@Tags("kpiUserCapacity") @Tags("kpiUserCapacity")
@ -93,6 +91,8 @@ export class KpiUserCapacityController extends Controller {
kpiUserCapacity.createdFullName = request.user.name; kpiUserCapacity.createdFullName = request.user.name;
kpiUserCapacity.lastUpdateUserId = request.user.sub; kpiUserCapacity.lastUpdateUserId = request.user.sub;
kpiUserCapacity.lastUpdateFullName = request.user.name; kpiUserCapacity.lastUpdateFullName = request.user.name;
kpiUserCapacity.createdAt = new Date();
kpiUserCapacity.lastUpdatedAt = new Date();
await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request }); await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request });
setLogDataDiff(request, { before, after: kpiUserCapacity }); setLogDataDiff(request, { before, after: kpiUserCapacity });
@ -160,6 +160,7 @@ export class KpiUserCapacityController extends Controller {
const _kpiUserCapacity = Object.assign(new KpiUserCapacity(), requestBody); const _kpiUserCapacity = Object.assign(new KpiUserCapacity(), requestBody);
kpiUserCapacity.lastUpdateUserId = request.user.sub; kpiUserCapacity.lastUpdateUserId = request.user.sub;
kpiUserCapacity.lastUpdateFullName = request.user.name; kpiUserCapacity.lastUpdateFullName = request.user.name;
kpiUserCapacity.lastUpdatedAt = new Date();
this.kpiUserCapacityRepository.merge(kpiUserCapacity, _kpiUserCapacity); this.kpiUserCapacityRepository.merge(kpiUserCapacity, _kpiUserCapacity);
await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request }); await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request });
setLogDataDiff(request, { before, after: kpiUserCapacity }); setLogDataDiff(request, { before, after: kpiUserCapacity });
@ -285,6 +286,7 @@ export class KpiUserCapacityController extends Controller {
this.kpiUserCapacityRepository.merge(kpiUserCapacity, item); this.kpiUserCapacityRepository.merge(kpiUserCapacity, item);
kpiUserCapacity.lastUpdateUserId = request.user.sub; kpiUserCapacity.lastUpdateUserId = request.user.sub;
kpiUserCapacity.lastUpdateFullName = request.user.name; kpiUserCapacity.lastUpdateFullName = request.user.name;
kpiUserCapacity.lastUpdatedAt = new Date();
await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request }); await this.kpiUserCapacityRepository.save(kpiUserCapacity, { data: request });
setLogDataDiff(request, { before, after: kpiUserCapacity }); setLogDataDiff(request, { before, after: kpiUserCapacity });
} }

View file

@ -29,7 +29,7 @@ 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";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/achievement/development") @Route("api/v1/kpi/user/achievement/development")
@Tags("KpiUserDevelopment") @Tags("KpiUserDevelopment")
@ -95,6 +95,8 @@ export class KpiUserDevelopmentController extends Controller {
kpiUserDevelopment.createdFullName = request.user.name; kpiUserDevelopment.createdFullName = request.user.name;
kpiUserDevelopment.lastUpdateUserId = request.user.sub; kpiUserDevelopment.lastUpdateUserId = request.user.sub;
kpiUserDevelopment.lastUpdateFullName = request.user.name; kpiUserDevelopment.lastUpdateFullName = request.user.name;
kpiUserDevelopment.createdAt = new Date();
kpiUserDevelopment.lastUpdatedAt = new Date();
await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request }); await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request });
setLogDataDiff(request, { before, after: kpiUserDevelopment }); setLogDataDiff(request, { before, after: kpiUserDevelopment });
@ -107,6 +109,8 @@ export class KpiUserDevelopmentController extends Controller {
data.createdFullName = request.user.name; data.createdFullName = request.user.name;
data.lastUpdateUserId = request.user.sub; data.lastUpdateUserId = request.user.sub;
data.lastUpdateFullName = request.user.name; data.lastUpdateFullName = request.user.name;
data.createdAt = new Date();
data.lastUpdatedAt = new Date();
data.kpiUserDevelopmentId = kpiUserDevelopment.id; data.kpiUserDevelopmentId = kpiUserDevelopment.id;
await this.developmentProjectRepository.save(data, { data: request }); await this.developmentProjectRepository.save(data, { data: request });
setLogDataDiff(request, { before, after: data }); setLogDataDiff(request, { before, after: data });
@ -179,6 +183,7 @@ export class KpiUserDevelopmentController extends Controller {
const before = structuredClone(kpiUserDevelopment); const before = structuredClone(kpiUserDevelopment);
kpiUserDevelopment.lastUpdateUserId = request.user.sub; kpiUserDevelopment.lastUpdateUserId = request.user.sub;
kpiUserDevelopment.lastUpdateFullName = request.user.name; kpiUserDevelopment.lastUpdateFullName = request.user.name;
kpiUserDevelopment.lastUpdatedAt = new Date();
Object.assign(kpiUserDevelopment, requestBody); Object.assign(kpiUserDevelopment, requestBody);
await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request }); await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request });
setLogDataDiff(request, { before, after: kpiUserDevelopment }); setLogDataDiff(request, { before, after: kpiUserDevelopment });
@ -192,6 +197,8 @@ export class KpiUserDevelopmentController extends Controller {
data.createdFullName = request.user.name; data.createdFullName = request.user.name;
data.lastUpdateUserId = request.user.sub; data.lastUpdateUserId = request.user.sub;
data.lastUpdateFullName = request.user.name; data.lastUpdateFullName = request.user.name;
data.createdAt = new Date();
data.lastUpdatedAt = new Date();
data.kpiUserDevelopmentId = kpiUserDevelopment.id; data.kpiUserDevelopmentId = kpiUserDevelopment.id;
await this.developmentProjectRepository.save(data, { data: request }); await this.developmentProjectRepository.save(data, { data: request });
setLogDataDiff(request, { before: null, after: data }); setLogDataDiff(request, { before: null, after: data });
@ -325,6 +332,7 @@ export class KpiUserDevelopmentController extends Controller {
this.kpiUserDevelopmentRepository.merge(kpiUserDevelopment, item); this.kpiUserDevelopmentRepository.merge(kpiUserDevelopment, item);
kpiUserDevelopment.lastUpdateUserId = request.user.sub; kpiUserDevelopment.lastUpdateUserId = request.user.sub;
kpiUserDevelopment.lastUpdateFullName = request.user.name; kpiUserDevelopment.lastUpdateFullName = request.user.name;
kpiUserDevelopment.lastUpdatedAt = new Date();
await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request }); await this.kpiUserDevelopmentRepository.save(kpiUserDevelopment, { data: request });
setLogDataDiff(request, { before, after: kpiUserDevelopment }); setLogDataDiff(request, { before, after: kpiUserDevelopment });
} }

View file

@ -34,10 +34,9 @@ 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";
import { KpiLink } from "../entities/kpiLink"; import { KpiLink } from "../entities/kpiLink";
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"; import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/evaluation") @Route("api/v1/kpi/user/evaluation")
@Tags("kpiUserEvaluation") @Tags("kpiUserEvaluation")
@ -53,7 +52,6 @@ export class KpiUserEvaluationController extends Controller {
private kpiCapacityRepository = AppDataSource.getRepository(KpiCapacity); private kpiCapacityRepository = AppDataSource.getRepository(KpiCapacity);
private kpiPositionRepository = AppDataSource.getRepository(Position); private kpiPositionRepository = AppDataSource.getRepository(Position);
private kpiLinkRepository = AppDataSource.getRepository(KpiLink); private kpiLinkRepository = AppDataSource.getRepository(KpiLink);
private kpiGroupRepository = AppDataSource.getRepository(KpiGroup);
/** /**
* API * API
@ -83,7 +81,7 @@ export class KpiUserEvaluationController extends Controller {
.then((x) => { .then((x) => {
profileId = x.profileId; profileId = x.profileId;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
@ -476,7 +474,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.child4Id = x.child4Id; kpiUserEvaluation.child4Id = x.child4Id;
isProbation = x.isProbation; isProbation = x.isProbation;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
} else { } else {
@ -503,7 +501,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.child4Id = x.child4Id; kpiUserEvaluation.child4Id = x.child4Id;
isProbation = x.isProbation; isProbation = x.isProbation;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
} }
@ -525,6 +523,8 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.createdAt = new Date();
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -642,7 +642,7 @@ export class KpiUserEvaluationController extends Controller {
level: levelForGourp, level: levelForGourp,
weight: 100, weight: 100,
}) })
.catch((error) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถสร้างข้อมูลสมรรถนะได้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถสร้างข้อมูลสมรรถนะได้");
}); });
} }
@ -685,6 +685,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdateFullName = request.user.name;
kpiUserEvaluation.lastUpdatedAt = new Date();
Object.assign(kpiUserEvaluation, requestBody); Object.assign(kpiUserEvaluation, requestBody);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -733,6 +734,7 @@ export class KpiUserEvaluationController extends Controller {
const before = structuredClone(kpiUserEvaluation); const before = structuredClone(kpiUserEvaluation);
kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdateFullName = request.user.name;
kpiUserEvaluation.lastUpdatedAt = new Date();
Object.assign(kpiUserEvaluation, requestBody); Object.assign(kpiUserEvaluation, requestBody);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -774,6 +776,7 @@ export class KpiUserEvaluationController extends Controller {
const before = structuredClone(kpiUserEvaluation); const before = structuredClone(kpiUserEvaluation);
kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdateFullName = request.user.name;
kpiUserEvaluation.lastUpdatedAt = new Date();
Object.assign(kpiUserEvaluation, requestBody); Object.assign(kpiUserEvaluation, requestBody);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -806,6 +809,7 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
return new HttpSuccess(kpiUserEvaluation.id); return new HttpSuccess(kpiUserEvaluation.id);
@ -837,6 +841,7 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
return new HttpSuccess(kpiUserEvaluation.id); return new HttpSuccess(kpiUserEvaluation.id);
@ -875,8 +880,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
} else if (requestBody.status.trim().toUpperCase() == "EVALUATING_EVALUATOR") { } else if (requestBody.status.trim().toUpperCase() == "EVALUATING_EVALUATOR") {
await new CallAPI() await new CallAPI()
.PostData(request, "/placement/noti/profile", { .PostData(request, "/placement/noti/profile", {
@ -888,13 +893,14 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
} }
const before = structuredClone(kpiUserEvaluation); 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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
return new HttpSuccess(kpiUserEvaluation.id); return new HttpSuccess(kpiUserEvaluation.id);
@ -975,7 +981,7 @@ export class KpiUserEvaluationController extends Controller {
.then((x) => { .then((x) => {
profileId = x.profileId; profileId = x.profileId;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
@ -1064,7 +1070,7 @@ export class KpiUserEvaluationController extends Controller {
.then((x) => { .then((x) => {
profileId = x.profileId; profileId = x.profileId;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
const list = await this.kpiUserEvalutionRepository.find({ const list = await this.kpiUserEvalutionRepository.find({
@ -1104,8 +1110,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
item.evaluationStatus = "NEW_COMMANDER"; item.evaluationStatus = "NEW_COMMANDER";
} }
} }
@ -1124,8 +1130,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
item.evaluationStatus = "NEW_COMMANDER_HIGH"; item.evaluationStatus = "NEW_COMMANDER_HIGH";
} }
} }
@ -1138,6 +1144,7 @@ export class KpiUserEvaluationController extends Controller {
const before = null; const before = null;
item.lastUpdateUserId = request.user.sub; item.lastUpdateUserId = request.user.sub;
item.lastUpdateFullName = request.user.name; item.lastUpdateFullName = request.user.name;
item.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(item, { data: request }); await this.kpiUserEvalutionRepository.save(item, { data: request });
setLogDataDiff(request, { before, after: item }); setLogDataDiff(request, { before, after: item });
}), }),
@ -1167,7 +1174,7 @@ export class KpiUserEvaluationController extends Controller {
.then((x) => { .then((x) => {
profileId = x.profileId; profileId = x.profileId;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
@ -1221,6 +1228,7 @@ export class KpiUserEvaluationController extends Controller {
const before = null; const before = null;
item.lastUpdateUserId = request.user.sub; item.lastUpdateUserId = request.user.sub;
item.lastUpdateFullName = request.user.name; item.lastUpdateFullName = request.user.name;
item.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(item, { data: request }); await this.kpiUserEvalutionRepository.save(item, { data: request });
setLogDataDiff(request, { before, after: item }); setLogDataDiff(request, { before, after: item });
}); });
@ -1250,7 +1258,7 @@ export class KpiUserEvaluationController extends Controller {
.then((x) => { .then((x) => {
profileId = x.profileId; profileId = x.profileId;
}) })
.catch((x) => { .catch(() => {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
@ -1301,6 +1309,7 @@ export class KpiUserEvaluationController extends Controller {
const before = null; const before = null;
item.lastUpdateUserId = request.user.sub; item.lastUpdateUserId = request.user.sub;
item.lastUpdateFullName = request.user.name; item.lastUpdateFullName = request.user.name;
item.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(item, { data: request }); await this.kpiUserEvalutionRepository.save(item, { data: request });
setLogDataDiff(request, { before, after: item }); setLogDataDiff(request, { before, after: item });
}); });
@ -1308,7 +1317,7 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess(); return new HttpSuccess();
} }
/** /**
* API (ADMIN) * API (ADMIN)
* *
* @summary (ADMIN) * @summary (ADMIN)
@ -1380,6 +1389,7 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
return new HttpSuccess(kpiUserEvaluation.id); return new HttpSuccess(kpiUserEvaluation.id);
@ -1425,8 +1435,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
kpiUserEvaluation.evaluationStatus = "COMPLETE"; kpiUserEvaluation.evaluationStatus = "COMPLETE";
} else { } else {
await new CallAPI() await new CallAPI()
@ -1439,8 +1449,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER"; kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER";
} }
const before = structuredClone(kpiUserEvaluation); const before = structuredClone(kpiUserEvaluation);
@ -1455,6 +1465,7 @@ 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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
return new HttpSuccess(kpiUserEvaluation.id); return new HttpSuccess(kpiUserEvaluation.id);
@ -1498,8 +1509,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
kpiUserEvaluation.evaluationStatus = "COMPLETE"; kpiUserEvaluation.evaluationStatus = "COMPLETE";
} else { } else {
await new CallAPI() await new CallAPI()
@ -1512,8 +1523,8 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH"; kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH";
} }
const before = structuredClone(kpiUserEvaluation); const before = structuredClone(kpiUserEvaluation);
@ -1522,6 +1533,7 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -1566,14 +1578,15 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
const before = structuredClone(kpiUserEvaluation); 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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
@ -1615,7 +1628,7 @@ export class KpiUserEvaluationController extends Controller {
pointSum: kpiUserEvaluation.summaryPoint, pointSum: kpiUserEvaluation.summaryPoint,
profileId: kpiUserEvaluation.profileId, profileId: kpiUserEvaluation.profileId,
}) })
.then(async (x) => {}); .then(async () => {});
kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => { kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => {
new CallAPI() new CallAPI()
@ -1636,7 +1649,7 @@ export class KpiUserEvaluationController extends Controller {
summary: kpiUserDevelopment.summary, summary: kpiUserDevelopment.summary,
point: kpiUserDevelopment.point, point: kpiUserDevelopment.point,
}) })
.then(async (x) => {}); .then(async () => {});
}); });
new CallAPI() new CallAPI()
.PostData(request, "/placement/noti/profile", { .PostData(request, "/placement/noti/profile", {
@ -1648,11 +1661,12 @@ export class KpiUserEvaluationController extends Controller {
isSendInbox: true, isSendInbox: true,
isSendNotification: true, isSendNotification: true,
}) })
.then((x) => {}) .then(() => {})
.catch((x) => {}); .catch(() => {});
const before = null; const before = null;
kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdateFullName = request.user.name;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });
}), }),
@ -1736,6 +1750,7 @@ export class KpiUserEvaluationController extends Controller {
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;
kpiUserEvaluation.lastUpdatedAt = new Date();
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request }); await this.kpiUserEvalutionRepository.save(kpiUserEvaluation, { data: request });
setLogDataDiff(request, { before, after: kpiUserEvaluation }); setLogDataDiff(request, { before, after: kpiUserEvaluation });

View file

@ -28,8 +28,7 @@ import { Not } from "typeorm";
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation"; import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
import { KpiPlan } from "../entities/kpiPlan"; import { KpiPlan } from "../entities/kpiPlan";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission"; import { setLogDataDiff } from "../interfaces/utils";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/achievement/planned") @Route("api/v1/kpi/user/achievement/planned")
@Tags("KpiUserPlanned") @Tags("KpiUserPlanned")
@ -96,6 +95,8 @@ export class KpiUserPlannedController extends Controller {
kpiUserPlanned.createdFullName = request.user.name; kpiUserPlanned.createdFullName = request.user.name;
kpiUserPlanned.lastUpdateUserId = request.user.sub; kpiUserPlanned.lastUpdateUserId = request.user.sub;
kpiUserPlanned.lastUpdateFullName = request.user.name; kpiUserPlanned.lastUpdateFullName = request.user.name;
kpiUserPlanned.createdAt = new Date();
kpiUserPlanned.lastUpdatedAt = new Date();
// kpiUserPlanned.documentInfoEvidence = request.user.documentInfoEvidence; // kpiUserPlanned.documentInfoEvidence = request.user.documentInfoEvidence;
// kpiUserPlanned.startDate = request.user.startDate; // kpiUserPlanned.startDate = request.user.startDate;
// kpiUserPlanned.endDate = request.user.endDate; // kpiUserPlanned.endDate = request.user.endDate;
@ -144,6 +145,7 @@ export class KpiUserPlannedController extends Controller {
const before = structuredClone(kpiUserPlanned); const before = structuredClone(kpiUserPlanned);
kpiUserPlanned.lastUpdateUserId = request.user.sub; kpiUserPlanned.lastUpdateUserId = request.user.sub;
kpiUserPlanned.lastUpdateFullName = request.user.name; kpiUserPlanned.lastUpdateFullName = request.user.name;
kpiUserPlanned.lastUpdatedAt = new Date();
// kpiUserPlanned.documentInfoEvidence = request.user.documentInfoEvidence; // kpiUserPlanned.documentInfoEvidence = request.user.documentInfoEvidence;
// kpiUserPlanned.startDate = request.user.startDate; // kpiUserPlanned.startDate = request.user.startDate;
// kpiUserPlanned.endDate = request.user.endDate; // kpiUserPlanned.endDate = request.user.endDate;
@ -300,6 +302,7 @@ export class KpiUserPlannedController extends Controller {
this.kpiUserPlannedRepository.merge(kpiUserPlanned, item); this.kpiUserPlannedRepository.merge(kpiUserPlanned, item);
kpiUserPlanned.lastUpdateUserId = request.user.sub; kpiUserPlanned.lastUpdateUserId = request.user.sub;
kpiUserPlanned.lastUpdateFullName = request.user.name; kpiUserPlanned.lastUpdateFullName = request.user.name;
kpiUserPlanned.lastUpdatedAt = new Date();
await this.kpiUserPlannedRepository.save(kpiUserPlanned, { data: request }); await this.kpiUserPlannedRepository.save(kpiUserPlanned, { data: request });
setLogDataDiff(request, { before, after: kpiUserPlanned }); setLogDataDiff(request, { before, after: kpiUserPlanned });
} }

View file

@ -28,8 +28,7 @@ import { Not } from "typeorm";
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation"; import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
import { KpiRole } from "../entities/kpiRole"; import { KpiRole } from "../entities/kpiRole";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission"; import { setLogDataDiff } from "../interfaces/utils";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/achievement/role") @Route("api/v1/kpi/user/achievement/role")
@Tags("KpiUserRole") @Tags("KpiUserRole")
@ -99,6 +98,8 @@ export class KpiUserRoleController extends Controller {
kpiUserRole.createdFullName = request.user.name; kpiUserRole.createdFullName = request.user.name;
kpiUserRole.lastUpdateUserId = request.user.sub; kpiUserRole.lastUpdateUserId = request.user.sub;
kpiUserRole.lastUpdateFullName = request.user.name; kpiUserRole.lastUpdateFullName = request.user.name;
kpiUserRole.createdAt = new Date();
kpiUserRole.lastUpdatedAt = new Date();
await this.kpiUserRoleRepository.save(kpiUserRole, { data: request }); await this.kpiUserRoleRepository.save(kpiUserRole, { data: request });
setLogDataDiff(request, { before, after: kpiUserRole }); setLogDataDiff(request, { before, after: kpiUserRole });
@ -156,6 +157,7 @@ export class KpiUserRoleController extends Controller {
const before = structuredClone(kpiUserRole); const before = structuredClone(kpiUserRole);
kpiUserRole.lastUpdateUserId = request.user.sub; kpiUserRole.lastUpdateUserId = request.user.sub;
kpiUserRole.lastUpdateFullName = request.user.name; kpiUserRole.lastUpdateFullName = request.user.name;
kpiUserRole.lastUpdatedAt = new Date();
Object.assign(kpiUserRole, requestBody); Object.assign(kpiUserRole, requestBody);
kpiUserRole.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; kpiUserRole.startDate = requestBody.startDate == undefined ? null : requestBody.startDate;
kpiUserRole.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; kpiUserRole.endDate = requestBody.endDate == undefined ? null : requestBody.endDate;
@ -305,6 +307,7 @@ export class KpiUserRoleController extends Controller {
this.kpiUserRoleRepository.merge(kpiUserRole, item); this.kpiUserRoleRepository.merge(kpiUserRole, item);
kpiUserRole.lastUpdateUserId = request.user.sub; kpiUserRole.lastUpdateUserId = request.user.sub;
kpiUserRole.lastUpdateFullName = request.user.name; kpiUserRole.lastUpdateFullName = request.user.name;
kpiUserRole.lastUpdatedAt = new Date();
await this.kpiUserRoleRepository.save(kpiUserRole, { data: request }); await this.kpiUserRoleRepository.save(kpiUserRole, { data: request });
setLogDataDiff(request, { before, after: kpiUserRole }); setLogDataDiff(request, { before, after: kpiUserRole });
} }

View file

@ -28,8 +28,7 @@ import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
import { KpiSpecial } from "../entities/kpiSpecial"; import { KpiSpecial } from "../entities/kpiSpecial";
import { Not } from "typeorm"; import { Not } from "typeorm";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission"; import { setLogDataDiff } from "../interfaces/utils";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/kpi/user/achievement/special") @Route("api/v1/kpi/user/achievement/special")
@Tags("KpiUserSpecial") @Tags("KpiUserSpecial")
@ -104,6 +103,8 @@ export class KpiUserSpecialController extends Controller {
kpiSpecial.createdFullName = request.user.name; kpiSpecial.createdFullName = request.user.name;
kpiSpecial.lastUpdateUserId = request.user.sub; kpiSpecial.lastUpdateUserId = request.user.sub;
kpiSpecial.lastUpdateFullName = request.user.name; kpiSpecial.lastUpdateFullName = request.user.name;
kpiSpecial.createdAt = new Date();
kpiSpecial.lastUpdatedAt = new Date();
await this.kpiSpecialRepository.save(kpiSpecial, { data: request }); await this.kpiSpecialRepository.save(kpiSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiSpecial }); setLogDataDiff(request, { before, after: kpiSpecial });
} }
@ -113,6 +114,8 @@ export class KpiUserSpecialController extends Controller {
kpiUserSpecial.createdFullName = request.user.name; kpiUserSpecial.createdFullName = request.user.name;
kpiUserSpecial.lastUpdateUserId = request.user.sub; kpiUserSpecial.lastUpdateUserId = request.user.sub;
kpiUserSpecial.lastUpdateFullName = request.user.name; kpiUserSpecial.lastUpdateFullName = request.user.name;
kpiUserSpecial.createdAt = new Date();
kpiUserSpecial.lastUpdatedAt = new Date();
await this.kpiUserSpecialRepository.save(kpiUserSpecial, { data: request }); await this.kpiUserSpecialRepository.save(kpiUserSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiUserSpecial }); setLogDataDiff(request, { before, after: kpiUserSpecial });
@ -181,12 +184,15 @@ export class KpiUserSpecialController extends Controller {
kpiSpecial.createdFullName = request.user.name; kpiSpecial.createdFullName = request.user.name;
kpiSpecial.lastUpdateUserId = request.user.sub; kpiSpecial.lastUpdateUserId = request.user.sub;
kpiSpecial.lastUpdateFullName = request.user.name; kpiSpecial.lastUpdateFullName = request.user.name;
kpiSpecial.createdAt = new Date();
kpiSpecial.lastUpdatedAt = new Date();
await this.kpiSpecialRepository.save(kpiSpecial, { data: request }); await this.kpiSpecialRepository.save(kpiSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiSpecial }); setLogDataDiff(request, { before, after: kpiSpecial });
} }
before = structuredClone(kpiUserSpecial); before = structuredClone(kpiUserSpecial);
kpiUserSpecial.lastUpdateUserId = request.user.sub; kpiUserSpecial.lastUpdateUserId = request.user.sub;
kpiUserSpecial.lastUpdateFullName = request.user.name; kpiUserSpecial.lastUpdateFullName = request.user.name;
kpiUserSpecial.lastUpdatedAt = new Date();
Object.assign(kpiUserSpecial, requestBody); Object.assign(kpiUserSpecial, requestBody);
kpiUserSpecial.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; kpiUserSpecial.startDate = requestBody.startDate == undefined ? null : requestBody.startDate;
kpiUserSpecial.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; kpiUserSpecial.endDate = requestBody.endDate == undefined ? null : requestBody.endDate;
@ -343,6 +349,7 @@ export class KpiUserSpecialController extends Controller {
this.kpiUserSpecialRepository.merge(kpiUserSpecial, item); this.kpiUserSpecialRepository.merge(kpiUserSpecial, item);
kpiUserSpecial.lastUpdateUserId = request.user.sub; kpiUserSpecial.lastUpdateUserId = request.user.sub;
kpiUserSpecial.lastUpdateFullName = request.user.name; kpiUserSpecial.lastUpdateFullName = request.user.name;
kpiUserSpecial.lastUpdatedAt = new Date();
await this.kpiUserSpecialRepository.save(kpiUserSpecial, { data: request }); await this.kpiUserSpecialRepository.save(kpiUserSpecial, { data: request });
setLogDataDiff(request, { before, after: kpiUserSpecial }); setLogDataDiff(request, { before, after: kpiUserSpecial });
} }

View file

@ -1,4 +1,4 @@
import { Controller, Get, Post, Put, Delete, Patch, Route, Security, Tags } from "tsoa"; import { Controller, Get, Route, Security, Tags } from "tsoa";
@Route("/hello") @Route("/hello")
@Tags("Test") @Tags("Test")

View file

@ -7,8 +7,6 @@ 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 Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import { KpiRole } from "../entities/kpiRole";
import { KpiPlan } from "../entities/kpiPlan";
import { KpiUserDevelopment } from "../entities/kpiUserDevelopment"; import { KpiUserDevelopment } from "../entities/kpiUserDevelopment";
import CallAPI from "../interfaces/call-api"; import CallAPI from "../interfaces/call-api";
@Route("api/v1/kpi/report") @Route("api/v1/kpi/report")
@ -17,8 +15,6 @@ import CallAPI from "../interfaces/call-api";
export class ReportController extends Controller { export class ReportController extends Controller {
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod); private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation); private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
private kpiPlanRepository = AppDataSource.getRepository(KpiPlan);
private kpiUserDevelopmentRepository = AppDataSource.getRepository(KpiUserDevelopment); private kpiUserDevelopmentRepository = AppDataSource.getRepository(KpiUserDevelopment);
@Post("announcement") @Post("announcement")
@ -44,7 +40,7 @@ export class ReportController extends Controller {
let dataKpiUserEvaluations: any; let dataKpiUserEvaluations: any;
let period1: any; let period1: any;
let period2: any; let period2: any;
let rootName: any let rootName: any;
if (requestBody.root && requestBody.periodId) { if (requestBody.root && requestBody.periodId) {
data = await this.kpiPeriodRepository.findOne({ data = await this.kpiPeriodRepository.findOne({
where: { id: requestBody.periodId }, where: { id: requestBody.periodId },
@ -56,11 +52,9 @@ export class ReportController extends Controller {
evaluationStatus: "KP7", evaluationStatus: "KP7",
}, },
}); });
await new CallAPI() await new CallAPI().GetData(request, `/org/root/${requestBody.root}`).then((x) => {
.GetData(request, `/org/root/${requestBody.root}`) rootName = x.orgRootName;
.then((x) => { });
rootName = x.orgRootName;
});
data = { data = {
id: data.id, id: data.id,
year: data.year, year: data.year,
@ -68,7 +62,7 @@ export class ReportController extends Controller {
startDate: data.startDate, startDate: data.startDate,
endDate: data.endDate, endDate: data.endDate,
kpiUserEvaluations: dataKpiUserEvaluations, kpiUserEvaluations: dataKpiUserEvaluations,
rootName: rootName rootName: rootName,
}; };
if (data.durationKPI == "APR") { if (data.durationKPI == "APR") {
@ -170,10 +164,7 @@ export class ReportController extends Controller {
period1: Extension.ToThaiNumber(period1), period1: Extension.ToThaiNumber(period1),
period2: Extension.ToThaiNumber(period2), period2: Extension.ToThaiNumber(period2),
durationKPI: data?.durationKPI, durationKPI: data?.durationKPI,
root: root: data && data.rootName != null ? data.rootName : "-",
data && data.rootName != null
? data.rootName
: "-",
userEvaluations: [ userEvaluations: [
{ {
no: userEvaluationOrg.length > 0 ? "๑" : "-", no: userEvaluationOrg.length > 0 ? "๑" : "-",
@ -205,172 +196,210 @@ export class ReportController extends Controller {
.filter((x: any) => x.evaluationResults == "EXCELLENT") .filter((x: any) => x.evaluationResults == "EXCELLENT")
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
org: x.org ? x.org : "-", org: x.org ? x.org : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
org: "-", posLevelName: "-",
}]; org: "-",
},
];
const verygood = const verygood =
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? data.kpiUserEvaluations ? data.kpiUserEvaluations
.filter((x: any) => x.evaluationResults == "VERY_GOOD") .filter((x: any) => x.evaluationResults == "VERY_GOOD")
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
org: x.org ? x.org : "-", org: x.org ? x.org : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
org: "-", posLevelName: "-",
}]; org: "-",
},
];
const good = const good =
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? data.kpiUserEvaluations ? data.kpiUserEvaluations
.filter((x: any) => x.evaluationResults == "GOOD") .filter((x: any) => x.evaluationResults == "GOOD")
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
org: x.org ? x.org : "-", org: x.org ? x.org : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
org: "-", posLevelName: "-",
}]; org: "-",
},
];
const fair = const fair =
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? data.kpiUserEvaluations ? data.kpiUserEvaluations
.filter((x: any) => x.evaluationResults == "FAIR") .filter((x: any) => x.evaluationResults == "FAIR")
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
org: x.org ? x.org : "-", org: x.org ? x.org : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
org: "-", posLevelName: "-",
}]; org: "-",
},
];
const improvment = const improvment =
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? data.kpiUserEvaluations ? data.kpiUserEvaluations
.filter((x: any) => x.evaluationResults == "IMPROVEMENT") .filter((x: any) => x.evaluationResults == "IMPROVEMENT")
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
org: x.org ? x.org : "-", org: x.org ? x.org : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
org: "-", posLevelName: "-",
}]; org: "-",
},
];
formattedData = { formattedData = {
year: data?.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-", year: data?.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
period1: Extension.ToThaiNumber(period1), period1: Extension.ToThaiNumber(period1),
period2: Extension.ToThaiNumber(period2), period2: Extension.ToThaiNumber(period2),
durationKPI: data?.durationKPI, durationKPI: data?.durationKPI,
root: data && data.rootName != null root: data && data.rootName != null ? data.rootName : "-",
? data.rootName
: "-",
excellents: { excellents: {
count: count:
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? Extension.ToThaiNumber(excellent.length.toString()) ? Extension.ToThaiNumber(excellent.length.toString())
: "", : "",
data: excellent.length > 0 ? excellent : [{ data:
no: "-", excellent.length > 0
fullName: "-", ? excellent
position: "-", : [
posLevelName: "-", {
org: "-", no: "-",
}], fullName: "-",
position: "-",
posLevelName: "-",
org: "-",
},
],
}, },
verygoods: { verygoods: {
count: count:
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? Extension.ToThaiNumber(verygood.length.toString()) ? Extension.ToThaiNumber(verygood.length.toString())
: "", : "",
data: verygood.length > 0 ? verygood : [{ data:
no: "-", verygood.length > 0
fullName: "-", ? verygood
position: "-", : [
posLevelName: "-", {
org: "-", no: "-",
}], fullName: "-",
position: "-",
posLevelName: "-",
org: "-",
},
],
}, },
goods: { goods: {
count: count:
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? Extension.ToThaiNumber(good.length.toString()) ? Extension.ToThaiNumber(good.length.toString())
: "", : "",
data: good.length > 0 ? good : [{ data:
no: "-", good.length > 0
fullName: "-", ? good
position: "-", : [
posLevelName: "-", {
org: "-", no: "-",
}], fullName: "-",
position: "-",
posLevelName: "-",
org: "-",
},
],
}, },
fairs: { fairs: {
count: count:
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? Extension.ToThaiNumber(fair.length.toString()) ? Extension.ToThaiNumber(fair.length.toString())
: "", : "",
data: fair.length > 0 ? fair : [{ data:
no: "-", fair.length > 0
fullName: "-", ? fair
position: "-", : [
posLevelName: "-", {
org: "-", no: "-",
}], fullName: "-",
position: "-",
posLevelName: "-",
org: "-",
},
],
}, },
improvments: { improvments: {
count: count:
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? Extension.ToThaiNumber(improvment.length.toString()) ? Extension.ToThaiNumber(improvment.length.toString())
: "", : "",
data: improvment.length > 0 ? improvment : [{ data:
no: "-", improvment.length > 0
fullName: "-", ? improvment
position: "-", : [
posLevelName: "-", {
org: "-", no: "-",
}], fullName: "-",
position: "-",
posLevelName: "-",
org: "-",
},
],
}, },
}; };
} }
@ -380,15 +409,14 @@ export class ReportController extends Controller {
const userEvaluations_ = const userEvaluations_ =
data?.kpiUserEvaluations?.length > 0 data?.kpiUserEvaluations?.length > 0
? data.kpiUserEvaluations.map((x: any, idx: number) => ({ ? data.kpiUserEvaluations.map((x: any, idx: number) => ({
no: idx != null ?Extension.ToThaiNumber((idx + 1).toString()) : "-", no: idx != null ? Extension.ToThaiNumber((idx + 1).toString()) : "-",
fullName: x.prefix != null && x.firstName != null && x.lastName != null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
point1: point1:
x.summaryPoint >= 90.0 x.summaryPoint >= 90.0 ? Extension.ToThaiNumber(x.summaryPoint.toString()) : "-",
? Extension.ToThaiNumber(x.summaryPoint.toString())
: "-",
point2: point2:
x.summaryPoint >= 80.0 && x.summaryPoint <= 89.99 x.summaryPoint >= 80.0 && x.summaryPoint <= 89.99
? Extension.ToThaiNumber(x.summaryPoint.toString()) ? Extension.ToThaiNumber(x.summaryPoint.toString())
@ -402,22 +430,22 @@ export class ReportController extends Controller {
? Extension.ToThaiNumber(x.summaryPoint.toString()) ? Extension.ToThaiNumber(x.summaryPoint.toString())
: "-", : "-",
point5: point5:
x.summaryPoint < 60.0 x.summaryPoint < 60.0 ? Extension.ToThaiNumber(x.summaryPoint.toString()) : "-",
? Extension.ToThaiNumber(x.summaryPoint.toString())
: "-",
remark: x.reasonEvaluator, remark: x.reasonEvaluator,
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
point1: "-", position: "-",
point2: "-", point1: "-",
point3: "-", point2: "-",
point4: "-", point3: "-",
point5: "-", point4: "-",
remark: "-", point5: "-",
}]; remark: "-",
},
];
const prefixEvaluator_ = const prefixEvaluator_ =
data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].prefixEvaluator : ""; data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].prefixEvaluator : "";
const firstNameEvaluator_ = const firstNameEvaluator_ =
@ -449,7 +477,7 @@ export class ReportController extends Controller {
posTypeNameCommander = x.posTypeName; posTypeNameCommander = x.posTypeName;
posLevelNameCommander = x.posLevelName; posLevelNameCommander = x.posLevelName;
}) })
.catch((x) => { .catch(() => {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
} }
@ -479,7 +507,7 @@ export class ReportController extends Controller {
posTypeNameCommanderHigh = x.posTypeName; posTypeNameCommanderHigh = x.posTypeName;
posLevelNameCommanderHigh = x.posLevelName; posLevelNameCommanderHigh = x.posLevelName;
}) })
.catch((x) => { .catch(() => {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
}); });
} }
@ -493,10 +521,7 @@ export class ReportController extends Controller {
period1: Extension.ToThaiNumber(period1), period1: Extension.ToThaiNumber(period1),
period2: Extension.ToThaiNumber(period2), period2: Extension.ToThaiNumber(period2),
durationKPI: data?.durationKPI, durationKPI: data?.durationKPI,
root: root: data && data.rootName != null ? data.rootName : "-",
data && data.rootName != null
? data.rootName
: "-",
fullNameEvaluator: fullNameEvaluator, fullNameEvaluator: fullNameEvaluator,
positionEvaluator: positionEvaluator:
data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].positionEvaluator : "-", data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].positionEvaluator : "-",
@ -541,7 +566,6 @@ export class ReportController extends Controller {
if (requestBody.type == "KPI4") { if (requestBody.type == "KPI4") {
templateName = "KPI4"; templateName = "KPI4";
reportName = "KPI4"; reportName = "KPI4";
const yearNow = new Date().getFullYear();
let combinedDatas: any; let combinedDatas: any;
if (requestBody.profileId) { if (requestBody.profileId) {
//ชั่วคราว //ชั่วคราว
@ -913,60 +937,61 @@ export class ReportController extends Controller {
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()), year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
}, },
); );
formattedData = profileEvaluation.length > 0 formattedData =
? combinedData profileEvaluation.length > 0
: { ? combinedData
fullName: "-", : {
position: "-", fullName: "-",
posType: "-", position: "-",
posLevel: "-", posType: "-",
affiliation: "-", posLevel: "-",
summaryPointAPR1: "-", affiliation: "-",
textPointAPR1: "-", summaryPointAPR1: "-",
periodAPR1: "-", textPointAPR1: "-",
yearAPR1: "-", periodAPR1: "-",
summaryPointOCT1: "-", yearAPR1: "-",
textPointOCT1: "-", summaryPointOCT1: "-",
periodOCT1: "-", textPointOCT1: "-",
yearOCT1: "-", periodOCT1: "-",
summaryPointAPR2: "-", yearOCT1: "-",
textPointAPR2: "-", summaryPointAPR2: "-",
periodAPR2: "-", textPointAPR2: "-",
yearAPR2: "-", periodAPR2: "-",
summaryPointOCT2: "-", yearAPR2: "-",
textPointOCT2: "-", summaryPointOCT2: "-",
periodOCT2: "-", textPointOCT2: "-",
yearOCT2: "-", periodOCT2: "-",
summaryPointAPR3: "-", yearOCT2: "-",
textPointAPR3: "-", summaryPointAPR3: "-",
periodAPR3: "-", textPointAPR3: "-",
yearAPR3: "-", periodAPR3: "-",
summaryPointOCT3: "-", yearAPR3: "-",
textPointOCT3: "-", summaryPointOCT3: "-",
periodOCT3: "-", textPointOCT3: "-",
yearOCT3: "-", periodOCT3: "-",
summaryPointAPR4: "-", yearOCT3: "-",
textPointAPR4: "-", summaryPointAPR4: "-",
periodAPR4: "-", textPointAPR4: "-",
yearAPR4: "-", periodAPR4: "-",
summaryPointOCT4: "-", yearAPR4: "-",
textPointOCT4: "-", summaryPointOCT4: "-",
periodOCT4: "-", textPointOCT4: "-",
yearOCT4: "-", periodOCT4: "-",
summaryPointAPR5: "-", yearOCT4: "-",
textPointAPR5: "-", summaryPointAPR5: "-",
periodAPR5: "-", textPointAPR5: "-",
yearAPR5: "-", periodAPR5: "-",
summaryPointOCT5: "-", yearAPR5: "-",
textPointOCT5: "-", summaryPointOCT5: "-",
periodOCT5: "-", textPointOCT5: "-",
yearOCT5: "-", periodOCT5: "-",
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()), yearOCT5: "-",
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()), year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()),
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()), year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()),
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()), year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()), year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
}; year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
};
// } // }
} }
} }
@ -1149,42 +1174,43 @@ export class ReportController extends Controller {
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()), year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
}, },
); );
formattedData = profileEvaluation.length > 0 formattedData =
? combinedData profileEvaluation.length > 0
: { ? combinedData
fullName: "-", : {
position: "-", fullName: "-",
posType: "-", position: "-",
posLevel: "-", posType: "-",
affiliation: "-", posLevel: "-",
summaryPointAPR1: "-", affiliation: "-",
textPointAPR1: "-", summaryPointAPR1: "-",
periodAPR1: "-", textPointAPR1: "-",
yearAPR1: "-", periodAPR1: "-",
summaryPointOCT1: "-", yearAPR1: "-",
textPointOCT1: "-", summaryPointOCT1: "-",
periodOCT1: "-", textPointOCT1: "-",
yearOCT1: "-", periodOCT1: "-",
summaryPointAPR2: "-", yearOCT1: "-",
textPointAPR2: "-", summaryPointAPR2: "-",
periodAPR2: "-", textPointAPR2: "-",
yearAPR2: "-", periodAPR2: "-",
summaryPointOCT2: "-", yearAPR2: "-",
textPointOCT2: "-", summaryPointOCT2: "-",
periodOCT2: "-", textPointOCT2: "-",
yearOCT2: "-", periodOCT2: "-",
summaryPointAPR3: "-", yearOCT2: "-",
textPointAPR3: "-", summaryPointAPR3: "-",
periodAPR3: "-", textPointAPR3: "-",
yearAPR3: "-", periodAPR3: "-",
summaryPointOCT3: "-", yearAPR3: "-",
textPointOCT3: "-", summaryPointOCT3: "-",
periodOCT3: "-", textPointOCT3: "-",
yearOCT3: "-", periodOCT3: "-",
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()), yearOCT3: "-",
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()), year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()), year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
}; year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
};
// } // }
} }
} }
@ -1210,9 +1236,10 @@ export class ReportController extends Controller {
// : "" // : ""
return { return {
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix != null && x.firstName != null && x.lastName != null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
developName: x.topicEvaluator ? x.topicEvaluator : "-", developName: x.topicEvaluator ? x.topicEvaluator : "-",
@ -1225,42 +1252,44 @@ export class ReportController extends Controller {
: "-", : "-",
}; };
}) })
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
developName: "-", posLevelName: "-",
developEvaluator: "-", developName: "-",
target: "-", developEvaluator: "-",
timeEvaluator: "-", target: "-",
developResults: "-", timeEvaluator: "-",
evaluationResults: "-" developResults: "-",
}], evaluationResults: "-",
},
],
); );
formattedData = { formattedData = {
year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-", year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
period1: Extension.ToThaiNumber(period1), period1: Extension.ToThaiNumber(period1),
period2: Extension.ToThaiNumber(period2), period2: Extension.ToThaiNumber(period2),
durationKPI: data.durationKPI, durationKPI: data.durationKPI,
root: root: data && data.rootName != null ? data.rootName : "-",
data && data.rootName != null userEvaluations:
? data.rootName userEvaluations_.length > 0
: "-", ? userEvaluations_
userEvaluations: userEvaluations_.length > 0 : [
? userEvaluations_ {
: [{ no: "-",
no: "-", fullName: "-",
fullName: "-", position: "-",
position: "-", posLevelName: "-",
posLevelName: "-", developName: "-",
developName: "-", developEvaluator: "-",
developEvaluator: "-", target: "-",
target: "-", timeEvaluator: "-",
timeEvaluator: "-", developResults: "-",
developResults: "-", evaluationResults: "-",
evaluationResults: "-" },
}], ],
}; };
} }
if (requestBody.type == "KPI8") { if (requestBody.type == "KPI8") {
@ -1395,45 +1424,47 @@ 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: formattedUserDevelopmentLists developments: formattedUserDevelopmentLists
? formattedUserDevelopmentLists ? formattedUserDevelopmentLists
: [{ : [
no:"-", {
name:"-", no: "-",
target:"-", name: "-",
summary:"-" target: "-",
}], summary: "-",
},
],
}; };
} }
if (requestBody.type == "KPI9") { if (requestBody.type == "KPI9") {
templateName = "KPI9"; templateName = "KPI9";
reportName = "KPI9"; reportName = "KPI9";
if(data && data.kpiUserEvaluations.length == 0) { if (data && data.kpiUserEvaluations.length == 0) {
//แก้ไขกรณีมีผู้ประเมินที่มีผลการประเมินดีเด่น แต่ RootId ไม่ตรงกับหน่วยงานที่ filter //แก้ไขกรณีมีผู้ประเมินที่มีผลการประเมินดีเด่น แต่ RootId ไม่ตรงกับหน่วยงานที่ filter
let userEvaInRoot: any let userEvaInRoot: any;
let userEvaOutRoot: any [] let userEvaOutRoot: any[];
userEvaInRoot = await this.kpiUserEvaluationRepository.findOne({ userEvaInRoot = await this.kpiUserEvaluationRepository.findOne({
select: ["org"], select: ["org"],
where: { where: {
kpiPeriodId: String(requestBody.periodId), kpiPeriodId: String(requestBody.periodId),
orgId: String(requestBody.root), orgId: String(requestBody.root),
}, },
}); });
if(userEvaInRoot) { if (userEvaInRoot) {
userEvaOutRoot = await this.kpiUserEvaluationRepository.find({ userEvaOutRoot = await this.kpiUserEvaluationRepository.find({
where: { where: {
kpiPeriodId: String(requestBody.periodId), kpiPeriodId: String(requestBody.periodId),
orgId: Not(String(requestBody.root)), orgId: Not(String(requestBody.root)),
org: userEvaInRoot.org, org: userEvaInRoot.org,
evaluationStatus: "KP7", evaluationStatus: "KP7",
}, },
}); });
if(userEvaOutRoot.length > 0) { if (userEvaOutRoot.length > 0) {
data.kpiUserEvaluations = userEvaOutRoot data.kpiUserEvaluations = userEvaOutRoot;
} }
} }
} }
const userEvaluations_ = const userEvaluations_ =
data.kpiUserEvaluations.length > 0 data.kpiUserEvaluations.length > 0
? data.kpiUserEvaluations ? data.kpiUserEvaluations
@ -1443,39 +1474,42 @@ export class ReportController extends Controller {
) )
.map((x: any, idx: number) => ({ .map((x: any, idx: number) => ({
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
fullName: x.prefix != null && x.firstName != null && x.lastName != null fullName:
? `${x.prefix}${x.firstName} ${x.lastName}` x.prefix != null && x.firstName != null && x.lastName != null
: "-", ? `${x.prefix}${x.firstName} ${x.lastName}`
: "-",
position: x.position ? x.position : "-", position: x.position ? x.position : "-",
posLevelName: x.posLevelName ? x.posLevelName : "-", posLevelName: x.posLevelName ? x.posLevelName : "-",
evaluationResults: x.evaluationResults evaluationResults: x.evaluationResults
? Extension.EvaluationResult(x.evaluationResults) ? Extension.EvaluationResult(x.evaluationResults)
: "-", : "-",
})) }))
: [{ : [
no: "-", {
fullName: "-", no: "-",
position: "-", fullName: "-",
posLevelName: "-", position: "-",
evaluationResults: "-", posLevelName: "-",
}]; evaluationResults: "-",
},
];
formattedData = { formattedData = {
root: root: data && data.rootName != null ? data.rootName : "-",
data && data.rootName != null
? data.rootName
: "-",
period: data?.durationKPI == "APR" ? "๑" : data?.durationKPI == "OCT" ? "๒" : "-", period: data?.durationKPI == "APR" ? "๑" : data?.durationKPI == "OCT" ? "๒" : "-",
year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-", year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
userEvaluations: userEvaluations_.length > 0 userEvaluations:
? userEvaluations_ userEvaluations_.length > 0
: [{ ? userEvaluations_
no: "-", : [
fullName: "-", {
position: "-", no: "-",
posLevelName: "-", fullName: "-",
evaluationResults: "-", position: "-",
}], posLevelName: "-",
evaluationResults: "-",
},
],
}; };
} }

View file

@ -45,20 +45,9 @@ class CheckAuth {
return null; return null;
} }
return await new CallAPI() return await new CallAPI()
.GetData(req, "/org/permission/org") .GetData(req, `/org/permission/org/${action}/${system}`)
.then(async (x) => { .then(async (x) => {
let privilege = null; let privilege = x.privilege;
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 = { let data: any = {
root: [null], root: [null],
child1: [null], child1: [null],