api รายการ kpiDev admin
This commit is contained in:
parent
e27bb54b39
commit
95922c5e73
1 changed files with 139 additions and 1 deletions
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from "../entities/kpiUserDevelopment";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { Not, Like } from "typeorm";
|
||||
import { Not, Like, Brackets } from "typeorm";
|
||||
|
||||
@Route("api/v1/kpi/user/achievement/development")
|
||||
@Tags("KpiUserDevelopment")
|
||||
|
|
@ -262,4 +262,142 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API
|
||||
*
|
||||
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด Admin
|
||||
*
|
||||
*/
|
||||
@Post("admin")
|
||||
async listKpiDevelopmentByStatusKP7(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
kpiPeriodId?: string;
|
||||
keyword?: string;
|
||||
// status?: string | null;
|
||||
// results?: string | null;
|
||||
// reqedit?: string | null;
|
||||
// evaluating?: boolean | null;
|
||||
},
|
||||
) {
|
||||
const [kpiUserDevelopment, total] = await AppDataSource.getRepository(KpiUserDevelopment)
|
||||
.createQueryBuilder("kpiUserDevelopment")
|
||||
.leftJoinAndSelect("kpiUserDevelopment.kpiUserEvaluation", "kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.where("kpiUserEvaluation.evaluationStatus = :status", { status: "KP7" })
|
||||
.andWhere("kpiUserEvaluation.kpiPeriodId = :kpiPeriodId", {
|
||||
kpiPeriodId: requestBody.kpiPeriodId,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserDevelopment.name LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.orderBy("kpiUserDevelopment.createdAt", "ASC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapData = kpiUserDevelopment.map((item) => {
|
||||
const fullNameParts = [
|
||||
item.kpiUserEvaluation.child4,
|
||||
item.kpiUserEvaluation.child3,
|
||||
item.kpiUserEvaluation.child2,
|
||||
item.kpiUserEvaluation.child1,
|
||||
item.kpiUserEvaluation.org,
|
||||
];
|
||||
|
||||
const organization = fullNameParts
|
||||
.filter((part) => part !== undefined && part !== null)
|
||||
.join("/");
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
durationKPI: item.kpiUserEvaluation.kpiPeriod.durationKPI,
|
||||
developmentName: item.name,
|
||||
prefix: item.kpiUserEvaluation.prefix ? item.kpiUserEvaluation.prefix : null,
|
||||
firstname: item.kpiUserEvaluation.firstName ? item.kpiUserEvaluation.firstName : null,
|
||||
lastname: item.kpiUserEvaluation.lastName ? item.kpiUserEvaluation.lastName : null,
|
||||
kpiPeriodId: item.kpiUserEvaluation.kpiPeriodId ? item.kpiUserEvaluation.kpiPeriodId : null,
|
||||
root: item.kpiUserEvaluation.org ? item.kpiUserEvaluation.org : null,
|
||||
position: item.kpiUserEvaluation.position ? item.kpiUserEvaluation.position : null,
|
||||
posTypeName: item.kpiUserEvaluation.posTypeName ? item.kpiUserEvaluation.posTypeName : null,
|
||||
posLevelName: item.kpiUserEvaluation.posLevelName
|
||||
? item.kpiUserEvaluation.posLevelName
|
||||
: null,
|
||||
organization: organization ? organization : null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({ data: mapData, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายการพัฒนาตนเอง Admin
|
||||
*
|
||||
* @summary - รายการพัฒนาตนเอง Admin #
|
||||
*
|
||||
*/
|
||||
@Get("admin/detail/{id}")
|
||||
async GetKpiDevelopmentStatusKP7ById(@Query("id") id: string) {
|
||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||
relations: [
|
||||
"kpiUserEvaluation",
|
||||
"kpiUserEvaluation.kpiPeriod",
|
||||
"kpiUserEvaluation.kpiUserCapacitys",
|
||||
"kpiUserEvaluation.kpiUserCapacitys.kpiCapacity",
|
||||
],
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
const formattedData = {
|
||||
id: kpiUserDevelopment?.id ?? null,
|
||||
evaluationId: kpiUserDevelopment?.kpiUserEvaluation.id ?? null,
|
||||
target: kpiUserDevelopment?.target ?? null,
|
||||
summary: kpiUserDevelopment?.summary ?? null,
|
||||
point: kpiUserDevelopment?.point ?? null,
|
||||
name: kpiUserDevelopment?.name ?? null,
|
||||
achievement10: kpiUserDevelopment?.achievement10 ?? null,
|
||||
achievement5: kpiUserDevelopment?.achievement5 ?? null,
|
||||
achievement0: kpiUserDevelopment?.achievement0 ?? null,
|
||||
isDevelopment70: kpiUserDevelopment?.isDevelopment70 ?? null,
|
||||
isDevelopment20: kpiUserDevelopment?.isDevelopment20 ?? null,
|
||||
isDevelopment10: kpiUserDevelopment?.isDevelopment10 ?? null,
|
||||
capacity:
|
||||
kpiUserDevelopment?.kpiUserEvaluation.kpiUserCapacitys.map((kpiUserCapacity) => ({
|
||||
capacityPoint: kpiUserCapacity.point,
|
||||
capacityName: kpiUserCapacity.kpiCapacity.name,
|
||||
})) ?? [],
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue