เพิ่มฟิวผู้บังคับ
This commit is contained in:
parent
ba00645cb8
commit
ecbb9c0d9f
7 changed files with 171 additions and 64 deletions
|
|
@ -37,32 +37,31 @@ export class kpiEvaluationController extends Controller {
|
|||
* @param id ไอดีของเกณฑ์การประเมิน
|
||||
*/
|
||||
@Put()
|
||||
async updateKpiEvaluations(
|
||||
@Body() requestBody: updateKpiEvaluation[],
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const updatedIds: string[] = [];
|
||||
async updateKpiEvaluations(
|
||||
@Body() requestBody: updateKpiEvaluation[],
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const updatedIds: string[] = [];
|
||||
|
||||
for (const item of requestBody) {
|
||||
const kpiEvaluation = await this.kpiEvaluationRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
if (!kpiEvaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, `ไม่พบข้อมูลเกณฑ์การประเมินนี้: ${item.id}`);
|
||||
for (const item of requestBody) {
|
||||
const kpiEvaluation = await this.kpiEvaluationRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
if (!kpiEvaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, `ไม่พบข้อมูลเกณฑ์การประเมินนี้: ${item.id}`);
|
||||
}
|
||||
|
||||
this.kpiEvaluationRepository.merge(kpiEvaluation, item);
|
||||
kpiEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiEvaluation.lastUpdateFullName = request.user.name;
|
||||
await this.kpiEvaluationRepository.save(kpiEvaluation);
|
||||
|
||||
updatedIds.push(item.id);
|
||||
}
|
||||
|
||||
this.kpiEvaluationRepository.merge(kpiEvaluation, item);
|
||||
kpiEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiEvaluation.lastUpdateFullName = request.user.name;
|
||||
await this.kpiEvaluationRepository.save(kpiEvaluation);
|
||||
|
||||
updatedIds.push(item.id);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API list เกณฑ์การประเมิน
|
||||
* @param page
|
||||
|
|
@ -81,20 +80,20 @@ async updateKpiEvaluations(
|
|||
where: [{ description: Like(`%${keyword}%`) }],
|
||||
};
|
||||
whereClause.where.push({ level: Like(`%${keyword}%`) });
|
||||
|
||||
}
|
||||
|
||||
|
||||
const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({
|
||||
...whereClause,
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
order:{
|
||||
level: "DESC"}
|
||||
order: {
|
||||
level: "DESC",
|
||||
},
|
||||
});
|
||||
|
||||
const formatted = kpiEvaluation.map((item) => ({
|
||||
id: item.id,
|
||||
level: item.level,
|
||||
description: item.description
|
||||
description: item.description,
|
||||
}));
|
||||
return new HttpSuccess({ data: formatted, total });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import { KpiPeriod } from "../entities/kpiPeriod";
|
|||
import {
|
||||
KpiUserEvaluation,
|
||||
createKpiUserEvaluation,
|
||||
updateKpiUserCheckEvaluation,
|
||||
updateKpiUserEvaluation,
|
||||
} from "../entities/kpiUserEvaluation";
|
||||
import { Like, In } from "typeorm";
|
||||
|
|
@ -120,6 +121,35 @@ export class KpiUserEvaluationController extends Controller {
|
|||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขคนประเมิน (USER)
|
||||
*
|
||||
* @summary แก้ไขคนประเมิน (USER)
|
||||
*
|
||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||
*/
|
||||
@Put("check/{id}")
|
||||
async updateKpiUserCheckEvaluation(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: updateKpiUserCheckEvaluation,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
Object.assign(kpiUserEvaluation, requestBody);
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
|
|
@ -136,7 +166,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!KpiUserEvaluation) {
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
|
|
@ -153,15 +183,13 @@ export class KpiUserEvaluationController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
if (kpiUserEvaluation) {
|
||||
// kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
|
||||
// kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
// kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
|
||||
// kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -173,7 +201,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiUserEvaluationById(@Path() id: string) {
|
||||
const KpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
select: [
|
||||
"id",
|
||||
|
|
@ -187,13 +215,13 @@ export class KpiUserEvaluationController extends Controller {
|
|||
"createdAt",
|
||||
],
|
||||
});
|
||||
if (!KpiUserEvaluation) {
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
return new HttpSuccess(KpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,16 +270,16 @@ export class KpiUserEvaluationController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiUserEvaluation(@Path() id: string) {
|
||||
const KpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!KpiUserEvaluation) {
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
await this.kpiUserEvalutionRepository.remove(KpiUserEvaluation);
|
||||
await this.kpiUserEvalutionRepository.remove(kpiUserEvaluation);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,12 @@ export class KpiUserPlannedController extends Controller {
|
|||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiPlanId: requestBody.kpiPlanId,
|
||||
},
|
||||
})
|
||||
});
|
||||
if (chk_indicator) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
const kpiUserPlanned = Object.assign(new KpiUserPlanned(), requestBody);
|
||||
|
|
@ -105,21 +108,23 @@ export class KpiUserPlannedController extends Controller {
|
|||
@Body() requestBody: UpdateKpiUserPlanned,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
|
||||
const kpiUserPlanned = await this.kpiUserPlannedRepository.findOne({ where: { id } });
|
||||
if (!kpiUserPlanned) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้");
|
||||
}
|
||||
|
||||
|
||||
const chk_indicator = await this.kpiUserPlannedRepository.findOne({
|
||||
where: {
|
||||
id: Not(id),
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiPlanId: requestBody.kpiPlanId,
|
||||
},
|
||||
})
|
||||
});
|
||||
if (chk_indicator) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
kpiUserPlanned.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
|
|
@ -76,15 +76,18 @@ export class KpiUserRoleController extends Controller {
|
|||
if (!kpiUserRole) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
|
||||
const chk_indicator = await this.kpiUserRoleRepository.findOne({
|
||||
where: {
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiRoleId: requestBody.kpiRoleId,
|
||||
},
|
||||
})
|
||||
});
|
||||
if (chk_indicator) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
kpiUserRole.createdUserId = request.user.sub;
|
||||
|
|
@ -128,16 +131,19 @@ export class KpiUserRoleController extends Controller {
|
|||
"ไม่พบข้อมูลแบบประเมินตามหน้าที่ความรับผิดชอบหลัก",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const chk_indicator = await this.kpiUserRoleRepository.findOne({
|
||||
where: {
|
||||
id: Not(id),
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiRoleId: requestBody.kpiRoleId,
|
||||
},
|
||||
})
|
||||
});
|
||||
if (chk_indicator) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
kpiUserRole.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
|
|
@ -63,17 +63,21 @@ export class KpiUserSpecialController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
|
||||
const chk_indicator = await this.kpiUserSpecialRepository.findOne({
|
||||
where: {
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
},
|
||||
})
|
||||
if (chk_indicator && chk_indicator.including == requestBody.including || chk_indicator && chk_indicator.includingName == requestBody.includingName) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
});
|
||||
if (
|
||||
(chk_indicator && chk_indicator.including == requestBody.including) ||
|
||||
(chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
kpiUserSpecial.createdUserId = request.user.sub;
|
||||
kpiUserSpecial.createdFullName = request.user.name;
|
||||
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -111,9 +115,15 @@ export class KpiUserSpecialController extends Controller {
|
|||
id: Not(id),
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
},
|
||||
})
|
||||
if (chk_indicator && chk_indicator.including == requestBody.including || chk_indicator && chk_indicator.includingName == requestBody.includingName) {
|
||||
throw new HttpError(HttpStatusCode.CONFLICT, "ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ");
|
||||
});
|
||||
if (
|
||||
(chk_indicator && chk_indicator.including == requestBody.including) ||
|
||||
(chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
|
|
@ -47,11 +47,36 @@ export class KpiUserEvaluation extends EntityBase {
|
|||
})
|
||||
profileId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "ไอดีผู้ประเมิน",
|
||||
default: null,
|
||||
})
|
||||
evaluatorId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "ไอดีผู้บังคับบัญชาเหนือขึ้นไป",
|
||||
default: null,
|
||||
})
|
||||
commanderId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "ไอดีผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
|
||||
default: null,
|
||||
})
|
||||
commanderHighId: string;
|
||||
|
||||
@Column({
|
||||
// "สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
|
||||
comment:
|
||||
"สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
|
||||
default: null,
|
||||
})
|
||||
evaluationStatus: string;
|
||||
|
|
@ -60,7 +85,8 @@ export class KpiUserEvaluation extends EntityBase {
|
|||
// "ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
|
||||
comment:
|
||||
"ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
|
||||
default: null,
|
||||
})
|
||||
evaluationResults: string;
|
||||
|
|
@ -93,6 +119,12 @@ export class createKpiUserEvaluation {
|
|||
kpiPeriodId: string;
|
||||
@Column()
|
||||
profileId: string;
|
||||
@Column()
|
||||
evaluatorId: string | null;
|
||||
@Column()
|
||||
commanderId: string | null;
|
||||
@Column()
|
||||
commanderHighId: string | null;
|
||||
}
|
||||
|
||||
export class updateKpiUserEvaluation {
|
||||
|
|
@ -107,3 +139,12 @@ export class updateKpiUserEvaluation {
|
|||
@Column()
|
||||
profileId: string;
|
||||
}
|
||||
|
||||
export class updateKpiUserCheckEvaluation {
|
||||
@Column()
|
||||
evaluatorId: string | null;
|
||||
@Column()
|
||||
commanderId: string | null;
|
||||
@Column()
|
||||
commanderHighId: string | null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableKpiUserEvalutionAddEvaluatorId1714111345274 implements MigrationInterface {
|
||||
name = 'UpdateTableKpiUserEvalutionAddEvaluatorId1714111345274'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluatorId\` varchar(40) NULL COMMENT 'ไอดีผู้ประเมิน'`);
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`commanderId\` varchar(40) NULL COMMENT 'ไอดีผู้บังคับบัญชาเหนือขึ้นไป'`);
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`commanderHighId\` varchar(40) NULL COMMENT 'ไอดีผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`commanderHighId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`commanderId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluatorId\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue