ผูกสิท
This commit is contained in:
parent
92b2291c4b
commit
5b63aa9fad
7 changed files with 181 additions and 22 deletions
|
|
@ -59,10 +59,7 @@ export class kpiPeriodController extends Controller {
|
||||||
startDate: "datetime", //วันเริ่มต้น
|
startDate: "datetime", //วันเริ่มต้น
|
||||||
endDate: "datetime", //วันสิ้นสุด
|
endDate: "datetime", //วันสิ้นสุด
|
||||||
})
|
})
|
||||||
async createKpi(
|
async createKpi(@Body() requestBody: createKpiPeriod, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: createKpiPeriod,
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request, "SYS_KPI_ROUND");
|
await new permission().PermissionCreate(request, "SYS_KPI_ROUND");
|
||||||
const chkkpiPeriod = await this.kpiPeriodRepository.findOne({
|
const chkkpiPeriod = await this.kpiPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -176,6 +173,35 @@ export class kpiPeriodController extends Controller {
|
||||||
return new HttpSuccess(kpiPeriod);
|
return new HttpSuccess(kpiPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API list รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||||
|
* @param page
|
||||||
|
* @param pageSize
|
||||||
|
* @param keyword
|
||||||
|
*/
|
||||||
|
@Get("user")
|
||||||
|
async listKpiPeriodUser(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Query("page") page: number = 1,
|
||||||
|
@Query("pageSize") pageSize: number = 10,
|
||||||
|
@Query("year") year?: number,
|
||||||
|
@Query("keyword") keyword?: string,
|
||||||
|
) {
|
||||||
|
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
||||||
|
.createQueryBuilder("kpiPeriod")
|
||||||
|
.andWhere(
|
||||||
|
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
||||||
|
{ year: year },
|
||||||
|
)
|
||||||
|
.orderBy("kpiPeriod.startDate", "ASC")
|
||||||
|
.addOrderBy("kpiPeriod.year", "ASC")
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: kpiPeriod, total });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
* API รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||||
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||||
|
|
@ -208,11 +234,13 @@ export class kpiPeriodController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiPeriod(
|
async listKpiPeriod(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("year") year?: number,
|
@Query("year") year?: number,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
await new permission().PermissionDelete(request, "SYS_KPI_ROUND");
|
||||||
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
||||||
.createQueryBuilder("kpiPeriod")
|
.createQueryBuilder("kpiPeriod")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
|
|
@ -220,7 +248,7 @@ export class kpiPeriodController extends Controller {
|
||||||
{ year: year },
|
{ year: year },
|
||||||
)
|
)
|
||||||
.orderBy("kpiPeriod.startDate", "ASC")
|
.orderBy("kpiPeriod.startDate", "ASC")
|
||||||
.addOrderBy("kpiPeriod.year", "ASC")
|
.addOrderBy("kpiPeriod.year", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,8 @@ export class KpiUserCapacityController extends Controller {
|
||||||
* @param {string} id Guid, *Id องค์ประกอบที่ 2 พฤติกรรมการปฎิบัติราชการ (สมรรถนะ) (USER)
|
* @param {string} id Guid, *Id องค์ประกอบที่ 2 พฤติกรรมการปฎิบัติราชการ (สมรรถนะ) (USER)
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserCapacityById(@Path() id: string) {
|
async GetKpiUserCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
|
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["kpiCapacity"],
|
relations: ["kpiCapacity"],
|
||||||
|
|
@ -197,9 +198,11 @@ export class KpiUserCapacityController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiUserCapacity(
|
async listKpiUserCapacity(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("id") id: string, //kpiUserEvaluationId
|
@Query("id") id: string, //kpiUserEvaluationId
|
||||||
@Query("type") type: string,
|
@Query("type") type: string,
|
||||||
) {
|
) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
||||||
.createQueryBuilder("kpiUserCapacity")
|
.createQueryBuilder("kpiUserCapacity")
|
||||||
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,8 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
* @param {string} id Id พัฒนาตนเอง
|
* @param {string} id Id พัฒนาตนเอง
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserDevelopmentDetail(@Path() id: string) {
|
async GetKpiUserDevelopmentDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
relations: ["kpiUserEvaluation", "developmentProjects"],
|
relations: ["kpiUserEvaluation", "developmentProjects"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -262,7 +263,8 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserDevelopment(@Query("id") id: string) {
|
async GetKpiUserDevelopment(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
|
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
@ -424,7 +426,11 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("admin/detail/{id}")
|
@Get("admin/detail/{id}")
|
||||||
async GetKpiDevelopmentStatusKP7ById(@Path("id") id: string) {
|
async GetKpiDevelopmentStatusKP7ById(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Path("id") id: string,
|
||||||
|
) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_RESULT");
|
||||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"kpiUserEvaluation",
|
"kpiUserEvaluation",
|
||||||
|
|
|
||||||
|
|
@ -198,9 +198,9 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("list")
|
@Post("list-announce")
|
||||||
async listKpiListEvaluation(
|
async listKpiListEvaluationAnnounce(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
page: number;
|
page: number;
|
||||||
|
|
@ -213,6 +213,124 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
evaluating?: boolean | null;
|
evaluating?: boolean | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
await new permission().PermissionDelete(request, "SYS_RESULT");
|
||||||
|
let conditionFullName =
|
||||||
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
|
.andWhere(requestBody.kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||||
|
kpiPeriodId: requestBody.kpiPeriodId,
|
||||||
|
})
|
||||||
|
.andWhere(
|
||||||
|
requestBody.status != null && requestBody.status != undefined
|
||||||
|
? "evaluationstatus LIKE :status"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
status:
|
||||||
|
requestBody.status == null || requestBody.status == undefined
|
||||||
|
? null
|
||||||
|
: requestBody.status.trim().toUpperCase(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
requestBody.results != null && requestBody.results != undefined
|
||||||
|
? "evaluationResults LIKE :results"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
results:
|
||||||
|
requestBody.results == null || requestBody.results == undefined
|
||||||
|
? null
|
||||||
|
: requestBody.results.trim().toUpperCase(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.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(conditionFullName, {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
|
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||||
|
.take(requestBody.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
const mapData = kpiUserEvaluation.map((item) => {
|
||||||
|
const fullNameParts = [item.child4, item.child3, item.child2, item.child1, item.org];
|
||||||
|
|
||||||
|
const organization = fullNameParts
|
||||||
|
.filter((part) => part !== undefined && part !== null)
|
||||||
|
.join("/");
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
profileId: item.profileId,
|
||||||
|
prefix: item.prefix,
|
||||||
|
firstname: item.firstName,
|
||||||
|
lastname: item.lastName,
|
||||||
|
kpiPeriodId: item.kpiPeriodId,
|
||||||
|
evaluationStatus: item.evaluationStatus,
|
||||||
|
evaluationResults: item.evaluationResults,
|
||||||
|
createdAt: item.createdAt,
|
||||||
|
evaluatorId: item.evaluatorId,
|
||||||
|
commanderId: item.commanderId,
|
||||||
|
commanderHighId: item.commanderHighId,
|
||||||
|
root: item.org ? item.org : null,
|
||||||
|
rootId: item.orgId ? item.orgId : null,
|
||||||
|
position: item.position ? item.position : null,
|
||||||
|
// posTypeId: item.posTypeId,
|
||||||
|
posTypeName: item.posTypeName ? item.posTypeName : null,
|
||||||
|
// posLevelId: item.posLevelId,
|
||||||
|
posLevelName: item.posLevelName ? item.posLevelName : null,
|
||||||
|
organization: organization ? organization : null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return new HttpSuccess({ data: mapData, total });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API
|
||||||
|
*
|
||||||
|
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("list")
|
||||||
|
async listKpiListEvaluation(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
requestBody: {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
kpiPeriodId?: string;
|
||||||
|
keyword?: string;
|
||||||
|
status?: string | null;
|
||||||
|
results?: string | null;
|
||||||
|
reqedit?: string | null;
|
||||||
|
evaluating?: boolean | null;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
await new permission().PermissionDelete(request, "SYS_KPI_LIST");
|
||||||
let conditionFullName =
|
let conditionFullName =
|
||||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
|
|
@ -1440,10 +1558,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||||
*/
|
*/
|
||||||
@Get("reason/{id}")
|
@Get("reason/{id}")
|
||||||
async getReasonKpiEvaluation(
|
async getReasonKpiEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
@Path() id: string,
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
@Request() request: { user: Record<string, any> },
|
|
||||||
) {
|
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: [
|
select: [
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,8 @@ export class KpiUserPlannedController extends Controller {
|
||||||
* @param {string} id Id งานตามแผนปฏิบัติราชการประจำปี
|
* @param {string} id Id งานตามแผนปฏิบัติราชการประจำปี
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserPlannedDetail(@Path() id: string) {
|
async GetKpiUserPlannedDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
||||||
relations: ["kpiPlan", "kpiUserEvaluation"],
|
relations: ["kpiPlan", "kpiUserEvaluation"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -225,7 +226,8 @@ export class KpiUserPlannedController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserPlanned(@Query("id") id: string) {
|
async GetKpiUserPlanned(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
|
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,8 @@ export class KpiUserRoleController extends Controller {
|
||||||
* @param {string} id Id งานตามหน้าที่ความรับผิดชอบหลัก
|
* @param {string} id Id งานตามหน้าที่ความรับผิดชอบหลัก
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserRoleDetail(@Path() id: string) {
|
async GetKpiUserRoleDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
|
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
|
||||||
relations: ["kpiRole", "kpiUserEvaluation"],
|
relations: ["kpiRole", "kpiUserEvaluation"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -227,7 +228,8 @@ export class KpiUserRoleController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserRole(@Query("id") id: string) {
|
async GetKpiUserRole(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const kpiUserRole = await this.kpiUserRoleRepository.find({
|
const kpiUserRole = await this.kpiUserRoleRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,8 @@ export class KpiUserSpecialController extends Controller {
|
||||||
* @param {string} id Id งานที่ได้รับมอบหมายพิเศษ
|
* @param {string} id Id งานที่ได้รับมอบหมายพิเศษ
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserSpecialDetail(@Path() id: string) {
|
async GetKpiUserSpecialDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const getKpiUserSpecial = await this.kpiUserSpecialRepository.findOne({
|
const getKpiUserSpecial = await this.kpiUserSpecialRepository.findOne({
|
||||||
relations: ["kpiUserEvaluation"],
|
relations: ["kpiUserEvaluation"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -263,7 +264,8 @@ export class KpiUserSpecialController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserSpecial(@Query("id") id: string) {
|
async GetKpiUserSpecial(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
|
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||||
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
|
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue