ผูกสิท
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", //วันเริ่มต้น
|
||||
endDate: "datetime", //วันสิ้นสุด
|
||||
})
|
||||
async createKpi(
|
||||
@Body() requestBody: createKpiPeriod,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
async createKpi(@Body() requestBody: createKpiPeriod, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_KPI_ROUND");
|
||||
const chkkpiPeriod = await this.kpiPeriodRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -176,6 +173,35 @@ export class kpiPeriodController extends Controller {
|
|||
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 รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
|
|
@ -208,11 +234,13 @@ export class kpiPeriodController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiPeriod(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year?: number,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
await new permission().PermissionDelete(request, "SYS_KPI_ROUND");
|
||||
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
||||
.createQueryBuilder("kpiPeriod")
|
||||
.andWhere(
|
||||
|
|
@ -220,7 +248,7 @@ export class kpiPeriodController extends Controller {
|
|||
{ year: year },
|
||||
)
|
||||
.orderBy("kpiPeriod.startDate", "ASC")
|
||||
.addOrderBy("kpiPeriod.year", "ASC")
|
||||
.addOrderBy("kpiPeriod.year", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ export class KpiUserCapacityController extends Controller {
|
|||
* @param {string} id Guid, *Id องค์ประกอบที่ 2 พฤติกรรมการปฎิบัติราชการ (สมรรถนะ) (USER)
|
||||
*/
|
||||
@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({
|
||||
where: { id: id },
|
||||
relations: ["kpiCapacity"],
|
||||
|
|
@ -197,9 +198,11 @@ export class KpiUserCapacityController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiUserCapacity(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("id") id: string, //kpiUserEvaluationId
|
||||
@Query("type") type: string,
|
||||
) {
|
||||
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
||||
.createQueryBuilder("kpiUserCapacity")
|
||||
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
* @param {string} id 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({
|
||||
relations: ["kpiUserEvaluation", "developmentProjects"],
|
||||
where: { id: id },
|
||||
|
|
@ -262,7 +263,8 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
@ -424,7 +426,11 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
relations: [
|
||||
"kpiUserEvaluation",
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@ export class KpiUserEvaluationController extends Controller {
|
|||
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||
*
|
||||
*/
|
||||
@Post("list")
|
||||
async listKpiListEvaluation(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Post("list-announce")
|
||||
async listKpiListEvaluationAnnounce(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
|
|
@ -213,6 +213,124 @@ export class KpiUserEvaluationController extends Controller {
|
|||
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 =
|
||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
|
|
@ -1440,10 +1558,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||
*/
|
||||
@Get("reason/{id}")
|
||||
async getReasonKpiEvaluation(
|
||||
@Path() id: string,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
async getReasonKpiEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
select: [
|
||||
|
|
|
|||
|
|
@ -183,7 +183,8 @@ export class KpiUserPlannedController extends Controller {
|
|||
* @param {string} id 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({
|
||||
relations: ["kpiPlan", "kpiUserEvaluation"],
|
||||
where: { id: id },
|
||||
|
|
@ -225,7 +226,8 @@ export class KpiUserPlannedController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
|
|
@ -185,7 +185,8 @@ export class KpiUserRoleController extends Controller {
|
|||
* @param {string} id 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({
|
||||
relations: ["kpiRole", "kpiUserEvaluation"],
|
||||
where: { id: id },
|
||||
|
|
@ -227,7 +228,8 @@ export class KpiUserRoleController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
|
|
@ -210,7 +210,8 @@ export class KpiUserSpecialController extends Controller {
|
|||
* @param {string} id 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({
|
||||
relations: ["kpiUserEvaluation"],
|
||||
where: { id: id },
|
||||
|
|
@ -263,7 +264,8 @@ export class KpiUserSpecialController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue