no message

This commit is contained in:
Kittapath 2024-06-13 11:48:15 +07:00
parent 0b632803fe
commit 4a07ca669c
3 changed files with 116 additions and 64 deletions

View file

@ -445,51 +445,30 @@ export class kpiPlanController extends Controller {
}
parameters.nodeId = `%${requestBody.nodeId}%`;
}
// if (requestBody.year && requestBody.period && requestBody.isNull === true) {
// condition += ` AND (kpiPlan.year LIKE :year OR kpiPlan.year IS NULL) AND (kpiPlan.period LIKE :period OR kpiPlan.period IS NULL)`;
// parameters.year = `%${requestBody.year}%`;
// parameters.period = `%${requestBody.period}%`;
// }
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
.createQueryBuilder("kpiPlan")
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
.andWhere(condition, parameters)
// .andWhere(
// requestBody.year && requestBody.period
// ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period"
// : "1=1",
// {
// year: `%${requestBody.year}%`,
// period: `%${requestBody.period}%`,
// },
// )
.andWhere(
requestBody.year
? "kpiPlan.year LIKE :year"
: "1=1",
{
year: `%${requestBody.year}%`,
},
)
.andWhere(
requestBody.period
? "kpiPlan.period LIKE :period"
: "1=1",
{
period: `%${requestBody.period}%`,
},
)
.andWhere(requestBody.year ? "kpiPlan.year LIKE :year" : "1=1", {
year: `%${requestBody.year}%`,
})
.andWhere(requestBody.period ? "kpiPlan.period LIKE :period" : "1=1", {
period: `%${requestBody.period}%`,
})
.andWhere(
new Brackets((qb) => {
qb.orWhere("kpiPlan.including LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
}).orWhere("kpiPlan.includingName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
}).orWhere("kpiPlan.year LIKE :keyword",{
keyword: `%${requestBody.keyword}%`
}).orWhere("kpiPlan.period LIKE :keyword",{
keyword: `%${requestBody.keyword}%`
});
})
.orWhere("kpiPlan.includingName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiPlan.year LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiPlan.period LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
});
}),
)
.select([
@ -594,21 +573,21 @@ export class kpiPlanController extends Controller {
return new HttpSuccess();
}
/**
/**
* API
* @param id Guid, *Id
*/
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
where: { kpiPlanId: id },
order:{
createdAt: "ASC"
}
});
if (!kpiPlanHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามแผนนี้");
}
return new HttpSuccess(kpiPlanHistory);
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
where: { kpiPlanId: id },
order: {
createdAt: "ASC",
},
});
if (!kpiPlanHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามแผนนี้");
}
return new HttpSuccess(kpiPlanHistory);
}
}

View file

@ -179,6 +179,79 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess({ data: mapData, total });
}
/**
* API
*
* @summary
*
*/
@Post("list")
async listKpiListEvaluation(
@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 [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
.createQueryBuilder("kpiUserEvaluation")
.andWhere(requestBody.kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
kpiPeriodId: requestBody.kpiPeriodId,
})
.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}%`,
});
}),
)
.orderBy("kpiUserEvaluation.createdAt", "ASC")
.skip((requestBody.page - 1) * requestBody.pageSize)
.take(requestBody.pageSize)
.getManyAndCount();
const mapData = kpiUserEvaluation.map((item) => ({
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,
}));
return new HttpSuccess({ data: mapData, total });
}
/**
* API (USER)
*