This commit is contained in:
parent
b512bf64f1
commit
e4403e507f
2 changed files with 42 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ import { Like, In, Not, IsNull } from "typeorm";
|
|||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
||||
|
||||
@Route("api/v1/kpi/capacity")
|
||||
@Tags("kpiCapacity")
|
||||
|
|
@ -38,6 +39,7 @@ import { setLogDataDiff } from "../interfaces/utils";
|
|||
export class kpiCapacityController extends Controller {
|
||||
private kpiCapacityRepository = AppDataSource.getRepository(KpiCapacity);
|
||||
private kpiCapacityDetailRepository = AppDataSource.getRepository(KpiCapacityDetail);
|
||||
private kpiUserCapacityRepository = AppDataSource.getRepository(KpiUserCapacity);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
|
||||
/**
|
||||
|
|
@ -478,9 +480,15 @@ export class kpiCapacityController extends Controller {
|
|||
const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({
|
||||
where: { kpiCapacityId: id },
|
||||
});
|
||||
const kpiUserCapacity = await this.kpiUserCapacityRepository.find({
|
||||
where: { kpiCapacityId: id },
|
||||
});
|
||||
if (kpiCapacityDetails.length > 0) {
|
||||
await this.kpiCapacityDetailRepository.remove(kpiCapacityDetails, { data: request });
|
||||
}
|
||||
if (kpiUserCapacity.length > 0) {
|
||||
await this.kpiUserCapacityRepository.remove(kpiUserCapacity, { data: request });
|
||||
}
|
||||
await this.kpiCapacityRepository.remove(kpiCapacity, { data: request });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
updateKpiUserReqEditEvaluation,
|
||||
updateKpiUserResultEvaluation,
|
||||
} from "../entities/kpiUserEvaluation";
|
||||
import { In, Brackets, IsNull, Not } from "typeorm";
|
||||
import { In, Brackets, IsNull, Not, MoreThanOrEqual } from "typeorm";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||
import { Position } from "../entities/position";
|
||||
|
|
@ -1843,4 +1843,37 @@ export class KpiUserEvaluationController extends Controller {
|
|||
|
||||
return new HttpSuccess(kpiUserEvaluation);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายการผลการประเมินภายใน 5 ปี
|
||||
*
|
||||
* @summary รายการผลการประเมินภายใน 5 ปี
|
||||
*
|
||||
* @param {string} id Guid, *Id คนประเมิน
|
||||
*/
|
||||
@Get("summaryFiveYear/{id}")
|
||||
async getsummaryFiveYear(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
const year = new Date().getFullYear();
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.find({
|
||||
relations: ["kpiPeriod"],
|
||||
where: {
|
||||
profileId: id ,
|
||||
evaluationResults: Not("PENDING"),
|
||||
evaluationStatus: "KP7",
|
||||
kpiPeriod: {
|
||||
year: MoreThanOrEqual(year - 5),
|
||||
}
|
||||
},
|
||||
select: ["id", "evaluationStatus", "evaluationResults", "kpiPeriod"],
|
||||
});
|
||||
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
|
||||
return new HttpSuccess(kpiUserEvaluation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue