add auery

This commit is contained in:
kittapath 2025-01-16 14:07:29 +07:00
parent 8a676e7d6e
commit 4c06594af8
5 changed files with 78 additions and 24 deletions

View file

@ -59,7 +59,10 @@ export class kpiPlanController extends Controller {
.where("kpiPeriod.year = :year", { year: requestBody.year }) .where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period }) .andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne(); .getOne();
const year = requestBody.year && parseInt(requestBody.year) > 0?parseInt(requestBody.year) + 543:"ดังกล่าว"; const year =
requestBody.year && parseInt(requestBody.year) > 0
? parseInt(requestBody.year) + 543
: "ดังกล่าว";
if (!kpiPeriod) { if (!kpiPeriod) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
throw new HttpError( throw new HttpError(
@ -453,6 +456,7 @@ export class kpiPlanController extends Controller {
if (kpiPlan.strategyChild5Id != null) { if (kpiPlan.strategyChild5Id != null) {
strategy = 5; strategy = 5;
strategyId = kpiPlan.strategyChild5Id; strategyId = kpiPlan.strategyChild5Id;
strategyName = kpiPlan.strategyChild5;
} else if (kpiPlan.strategyChild4Id != null) { } else if (kpiPlan.strategyChild4Id != null) {
strategy = 4; strategy = 4;
strategyId = kpiPlan.strategyChild4Id; strategyId = kpiPlan.strategyChild4Id;
@ -870,11 +874,11 @@ export class kpiPlanController extends Controller {
type = 4; type = 4;
} }
const _null:any = null; const _null: any = null;
await this.kpiPlanHistoryRepository.delete({ kpiPlanId: id }); await this.kpiPlanHistoryRepository.delete({ kpiPlanId: id });
await this.kpiUserPlanRepository.update({ kpiPlanId: id },{ kpiPlanId: _null }); await this.kpiUserPlanRepository.update({ kpiPlanId: id }, { kpiPlanId: _null });
await this.kpiPlanRepository.remove(kpiPlan, { data: request }); await this.kpiPlanRepository.remove(kpiPlan, { data: request });
if (kpiPlan) { if (kpiPlan) {
let remainingKpiPlans: any; let remainingKpiPlans: any;
if (type == 0) { if (type == 0) {

View file

@ -526,6 +526,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.posLevelName = x.posLevelName; kpiUserEvaluation.posLevelName = x.posLevelName;
kpiUserEvaluation.posTypeName = x.posTypeName; kpiUserEvaluation.posTypeName = x.posTypeName;
kpiUserEvaluation.posExecutiveName = x.posExecutiveName; kpiUserEvaluation.posExecutiveName = x.posExecutiveName;
kpiUserEvaluation.isProbation = x.isProbation;
kpiUserEvaluation.org = x.root; kpiUserEvaluation.org = x.root;
kpiUserEvaluation.orgId = x.rootId; kpiUserEvaluation.orgId = x.rootId;
kpiUserEvaluation.child1 = x.child1; kpiUserEvaluation.child1 = x.child1;
@ -553,6 +554,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.posLevelName = x.posLevelName; kpiUserEvaluation.posLevelName = x.posLevelName;
kpiUserEvaluation.posTypeName = x.posTypeName; kpiUserEvaluation.posTypeName = x.posTypeName;
kpiUserEvaluation.posExecutiveName = x.posExecutiveName; kpiUserEvaluation.posExecutiveName = x.posExecutiveName;
kpiUserEvaluation.isProbation = x.isProbation;
kpiUserEvaluation.org = x.root; kpiUserEvaluation.org = x.root;
kpiUserEvaluation.orgId = x.rootId; kpiUserEvaluation.orgId = x.rootId;
kpiUserEvaluation.child1 = x.child1; kpiUserEvaluation.child1 = x.child1;
@ -1058,6 +1060,7 @@ export class KpiUserEvaluationController extends Controller {
evaluationStatus: kpiUserEvaluation.evaluationStatus, evaluationStatus: kpiUserEvaluation.evaluationStatus,
evaluationResults: kpiUserEvaluation.evaluationResults, evaluationResults: kpiUserEvaluation.evaluationResults,
evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit, evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit,
isProbation: kpiUserEvaluation.isProbation,
createdAt: kpiUserEvaluation.createdAt, createdAt: kpiUserEvaluation.createdAt,
evaluatorId: kpiUserEvaluation.evaluatorId, evaluatorId: kpiUserEvaluation.evaluatorId,
commanderId: kpiUserEvaluation.commanderId, commanderId: kpiUserEvaluation.commanderId,
@ -1482,6 +1485,7 @@ export class KpiUserEvaluationController extends Controller {
evaluationStatus: kpiUserEvaluation.evaluationStatus, evaluationStatus: kpiUserEvaluation.evaluationStatus,
evaluationResults: kpiUserEvaluation.evaluationResults, evaluationResults: kpiUserEvaluation.evaluationResults,
evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit, evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit,
isProbation: kpiUserEvaluation.isProbation,
createdAt: kpiUserEvaluation.createdAt, createdAt: kpiUserEvaluation.createdAt,
evaluatorId: kpiUserEvaluation.evaluatorId, evaluatorId: kpiUserEvaluation.evaluatorId,
commanderId: kpiUserEvaluation.commanderId, commanderId: kpiUserEvaluation.commanderId,

View file

@ -198,12 +198,38 @@ export class KpiUserPlannedController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้");
} }
let nodeName = null;
if (getKpiUserPlanned.kpiPlan.child4Id != null) {
nodeName = getKpiUserPlanned.kpiPlan.child4;
} else if (getKpiUserPlanned.kpiPlan.child3Id != null) {
nodeName = getKpiUserPlanned.kpiPlan.child3;
} else if (getKpiUserPlanned.kpiPlan.child2Id != null) {
nodeName = getKpiUserPlanned.kpiPlan.child2;
} else if (getKpiUserPlanned.kpiPlan.child1Id != null) {
nodeName = getKpiUserPlanned.kpiPlan.child1;
} else if (getKpiUserPlanned.kpiPlan.rootId != null) {
nodeName = getKpiUserPlanned.kpiPlan.root;
}
let strategyName = null;
if (getKpiUserPlanned.kpiPlan.strategyChild5Id != null) {
strategyName = getKpiUserPlanned.kpiPlan.strategyChild5;
} else if (getKpiUserPlanned.kpiPlan.strategyChild4Id != null) {
strategyName = getKpiUserPlanned.kpiPlan.strategyChild4;
} else if (getKpiUserPlanned.kpiPlan.strategyChild3Id != null) {
strategyName = getKpiUserPlanned.kpiPlan.strategyChild3;
} else if (getKpiUserPlanned.kpiPlan.strategyChild2Id != null) {
strategyName = getKpiUserPlanned.kpiPlan.strategyChild2;
} else if (getKpiUserPlanned.kpiPlan.strategyChild1Id != null) {
strategyName = getKpiUserPlanned.kpiPlan.strategyChild1;
}
const mapGetKpiUserPlanned = { const mapGetKpiUserPlanned = {
id: getKpiUserPlanned.id, id: getKpiUserPlanned.id,
evaluationId: getKpiUserPlanned.kpiUserEvaluation.id, evaluationId: getKpiUserPlanned.kpiUserEvaluation.id,
kpiPlanId: getKpiUserPlanned.kpiPlan.id, kpiPlanId: getKpiUserPlanned.kpiPlan.id,
including: getKpiUserPlanned.kpiPlan.including, //รหัสตัวชี้วัด including: getKpiUserPlanned.kpiPlan.including, //รหัสตัวชี้วัด
includingName: getKpiUserPlanned.kpiPlan.includingName, //ชื่อตัวชี้วัด includingName: getKpiUserPlanned.kpiPlan.includingName, //ชื่อตัวชี้วัด
nodeName: nodeName,
strategyName: strategyName,
target: getKpiUserPlanned.target, target: getKpiUserPlanned.target,
weight: getKpiUserPlanned.weight, weight: getKpiUserPlanned.weight,
unit: getKpiUserPlanned.unit, unit: getKpiUserPlanned.unit,
@ -254,21 +280,21 @@ export class KpiUserPlannedController extends Controller {
point: item.point, point: item.point,
achievement: achievement:
item.point === 1 item.point === 1
? item.kpiPlan.achievement1 ? item.achievement1
: item.point === 2 : item.point === 2
? item.kpiPlan.achievement2 ? item.achievement2
: item.point === 3 : item.point === 3
? item.kpiPlan.achievement3 ? item.achievement3
: item.point === 4 : item.point === 4
? item.kpiPlan.achievement4 ? item.achievement4
: item.point === 5 : item.point === 5
? item.kpiPlan.achievement5 ? item.achievement5
: null, : null,
achievement1: item.kpiPlan.achievement1, achievement1: item.achievement1,
achievement2: item.kpiPlan.achievement2, achievement2: item.achievement2,
achievement3: item.kpiPlan.achievement3, achievement3: item.achievement3,
achievement4: item.kpiPlan.achievement4, achievement4: item.achievement4,
achievement5: item.kpiPlan.achievement5, achievement5: item.achievement5,
})); }));
return new HttpSuccess(mapKpiUserPlanned); return new HttpSuccess(mapKpiUserPlanned);
} }

View file

@ -202,12 +202,25 @@ export class KpiUserRoleController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้");
} }
let nodeName = null;
if (getKpiUserRole.kpiRole.child4Id != null) {
nodeName = getKpiUserRole.kpiRole.child4;
} else if (getKpiUserRole.kpiRole.child3Id != null) {
nodeName = getKpiUserRole.kpiRole.child3;
} else if (getKpiUserRole.kpiRole.child2Id != null) {
nodeName = getKpiUserRole.kpiRole.child2;
} else if (getKpiUserRole.kpiRole.child1Id != null) {
nodeName = getKpiUserRole.kpiRole.child1;
} else if (getKpiUserRole.kpiRole.rootId != null) {
nodeName = getKpiUserRole.kpiRole.root;
}
const mapKpiUserRole = { const mapKpiUserRole = {
id: getKpiUserRole.id, id: getKpiUserRole.id,
evaluationId: getKpiUserRole.kpiUserEvaluation.id, evaluationId: getKpiUserRole.kpiUserEvaluation.id,
kpiRoleId: getKpiUserRole.kpiRole.id, kpiRoleId: getKpiUserRole.kpiRole.id,
including: getKpiUserRole.kpiRole.including, including: getKpiUserRole.kpiRole.including,
includingName: getKpiUserRole.kpiRole.includingName, includingName: getKpiUserRole.kpiRole.includingName,
nodeName: nodeName,
target: getKpiUserRole.target, target: getKpiUserRole.target,
weight: getKpiUserRole.weight, weight: getKpiUserRole.weight,
unit: getKpiUserRole.unit, unit: getKpiUserRole.unit,
@ -259,21 +272,21 @@ export class KpiUserRoleController extends Controller {
point: item.point, point: item.point,
achievement: achievement:
item.point === 1 item.point === 1
? item.kpiRole.achievement1 ? item.achievement1
: item.point === 2 : item.point === 2
? item.kpiRole.achievement2 ? item.achievement2
: item.point === 3 : item.point === 3
? item.kpiRole.achievement3 ? item.achievement3
: item.point === 4 : item.point === 4
? item.kpiRole.achievement4 ? item.achievement4
: item.point === 5 : item.point === 5
? item.kpiRole.achievement5 ? item.achievement5
: null, : null,
achievement1: item.kpiRole.achievement1, achievement1: item.achievement1,
achievement2: item.kpiRole.achievement2, achievement2: item.achievement2,
achievement3: item.kpiRole.achievement3, achievement3: item.achievement3,
achievement4: item.kpiRole.achievement4, achievement4: item.achievement4,
achievement5: item.kpiRole.achievement5, achievement5: item.achievement5,
})); }));
return new HttpSuccess(mapKpiUserRole); return new HttpSuccess(mapKpiUserRole);
} }

View file

@ -481,6 +481,13 @@ export class KpiUserEvaluation extends EntityBase {
}) })
isOpen: boolean; isOpen: boolean;
@Column({
nullable: true,
comment: "สถานะทดลองงาน",
default: false,
})
isProbation: boolean;
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",