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

View file

@ -179,6 +179,79 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess({ data: mapData, total }); 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) * API (USER)
* *

View file

@ -185,20 +185,20 @@ export class KpiUserEvaluation extends EntityBase {
} }
export class createKpiUserEvaluation { export class createKpiUserEvaluation {
// @Column() @Column()
// prefix: string; prefix?: string | null;
// @Column() @Column()
// firstName: string; firstName?: string | null;
// @Column() @Column()
// lastName: string; lastName?: string | null;
// @Column() @Column()
// position: string | null; position?: string | null;
// @Column() @Column()
// posTypeName: string | null; posTypeName?: string | null;
// @Column() @Column()
// posLevelName: string | null; posLevelName?: string | null;
// @Column() @Column()
// posExecutiveName: string | null; posExecutiveName?: string | null;
@Column() @Column()
kpiPeriodId: string; kpiPeriodId: string;
@Column() @Column()