Merge branch 'develop' into adiDev
This commit is contained in:
commit
98a28db920
4 changed files with 102 additions and 65 deletions
|
|
@ -45,12 +45,12 @@ export class kpiSpecialController extends Controller {
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
including: String(requestBody.including),
|
including: String(requestBody.including),
|
||||||
includingName: String(requestBody.includingName),
|
includingName: String(requestBody.includingName),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if(chk_kpiSpecial){
|
if (chk_kpiSpecial) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.CONFLICT,
|
HttpStatusCode.CONFLICT,
|
||||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||||
|
|
@ -88,13 +88,13 @@ export class kpiSpecialController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
including: String(requestBody.including),
|
including: String(requestBody.including),
|
||||||
includingName: String(requestBody.includingName),
|
includingName: String(requestBody.includingName),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if(chk_kpiSpecial){
|
if (chk_kpiSpecial) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.CONFLICT,
|
HttpStatusCode.CONFLICT,
|
||||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||||
|
|
@ -114,7 +114,7 @@ export class kpiSpecialController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiSpecialById(@Path() id: string) {
|
async GetKpiSpecialById(@Path() id: string) {
|
||||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: { id: id }
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!KpiSpecial) {
|
if (!KpiSpecial) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัด Specialนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัด Specialนี้");
|
||||||
|
|
@ -151,50 +151,61 @@ export class kpiSpecialController extends Controller {
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param keyword
|
* @param keyword
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Post("search")
|
||||||
async listKpiSpecial(
|
async listKpiSpecial(
|
||||||
@Query("page") page: number = 1,
|
@Body()
|
||||||
@Query("pageSize") pageSize: number = 10,
|
requestBody: {
|
||||||
@Query("keyword") keyword?: string,
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
year?: string | null;
|
||||||
|
period?: string | null;
|
||||||
|
keyword?: string | null;
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
let whereClause: any = {};
|
let condition: any = {};
|
||||||
if (keyword !== undefined && keyword !== "") {
|
if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
||||||
whereClause = {
|
condition = {
|
||||||
where: [{
|
where: [
|
||||||
including: Like(`%${keyword}%`),
|
{
|
||||||
includingName: Like(`%${keyword}%`),
|
including: Like(`%${requestBody.keyword}%`),
|
||||||
}],
|
includingName: Like(`%${requestBody.keyword}%`),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const [kpiSpecial, total] = await this.kpiSpecialRepository.findAndCount({
|
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
|
||||||
...whereClause,
|
.createQueryBuilder("kpiSpecial")
|
||||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
.andWhere(condition)
|
||||||
order: { createdAt: "ASC" },
|
.andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", {
|
||||||
});
|
year: `%${requestBody.year}%`,
|
||||||
const mapData = kpiSpecial.map((KpiSpecial) => ({
|
})
|
||||||
id: KpiSpecial.id,
|
.andWhere(requestBody.period ? "kpiSpecial.period LIKE :period" : "1=1", {
|
||||||
period: KpiSpecial.period,
|
period: `%${requestBody.period}%`,
|
||||||
year: KpiSpecial.year,
|
})
|
||||||
including: KpiSpecial.including,
|
.andWhere(
|
||||||
includingName: KpiSpecial.includingName,
|
new Brackets((qb) => {
|
||||||
target: KpiSpecial.target,
|
qb.orWhere("kpiSpecial.including LIKE :keyword", {
|
||||||
unit: KpiSpecial.unit,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
weight: KpiSpecial.weight,
|
}).orWhere("kpiSpecial.includingName LIKE :keyword", {
|
||||||
point: KpiSpecial.point,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
summary: KpiSpecial.summary,
|
});
|
||||||
documentInfoEvidence: KpiSpecial.documentInfoEvidence,
|
}),
|
||||||
startDate: KpiSpecial.startDate,
|
)
|
||||||
endDate: KpiSpecial.endDate,
|
.select([
|
||||||
achievement1: KpiSpecial.achievement1,
|
"kpiSpecial.id",
|
||||||
achievement2: KpiSpecial.achievement2,
|
"kpiSpecial.year",
|
||||||
achievement3: KpiSpecial.achievement3,
|
"kpiSpecial.period",
|
||||||
achievement4: KpiSpecial.achievement4,
|
"kpiSpecial.including",
|
||||||
achievement5: KpiSpecial.achievement5,
|
"kpiSpecial.includingName",
|
||||||
meaning: KpiSpecial.meaning,
|
"kpiSpecial.createdAt",
|
||||||
formula: KpiSpecial.formula,
|
])
|
||||||
}));
|
.orderBy("kpiSpecial.createdAt", "DESC")
|
||||||
return new HttpSuccess({ data: mapData, total });
|
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||||
|
.take(requestBody.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: kpiSpecial, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -240,25 +240,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserEvaluationById(@Path() id: string) {
|
async GetKpiUserEvaluationById(@Path() id: string) {
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
|
relations:["kpiPeriod"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"profileId",
|
|
||||||
"prefix",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"kpiPeriodId",
|
|
||||||
"evaluationStatus",
|
|
||||||
"evaluationResults",
|
|
||||||
"createdAt",
|
|
||||||
"evaluatorId",
|
|
||||||
"commanderId",
|
|
||||||
"commanderHighId",
|
|
||||||
"plannedPoint",
|
|
||||||
"rolePoint",
|
|
||||||
"specialPoint",
|
|
||||||
"capacityPoint",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
if (!kpiUserEvaluation) {
|
if (!kpiUserEvaluation) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -266,7 +249,27 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new HttpSuccess(kpiUserEvaluation);
|
const mapData = {
|
||||||
|
id: kpiUserEvaluation.id,
|
||||||
|
profileId: kpiUserEvaluation.profileId,
|
||||||
|
prefix: kpiUserEvaluation.prefix,
|
||||||
|
firstName: kpiUserEvaluation.firstName,
|
||||||
|
lastName: kpiUserEvaluation.lastName,
|
||||||
|
evaluationStatus: kpiUserEvaluation.evaluationStatus,
|
||||||
|
evaluationResults: kpiUserEvaluation.evaluationResults,
|
||||||
|
createdAt: kpiUserEvaluation.createdAt,
|
||||||
|
evaluatorId: kpiUserEvaluation.evaluatorId,
|
||||||
|
commanderId: kpiUserEvaluation.commanderId,
|
||||||
|
commanderHighId: kpiUserEvaluation.commanderHighId,
|
||||||
|
plannedPoint: kpiUserEvaluation.plannedPoint,
|
||||||
|
rolePoint: kpiUserEvaluation.rolePoint,
|
||||||
|
specialPoint: kpiUserEvaluation.specialPoint,
|
||||||
|
capacityPoint: kpiUserEvaluation.capacityPoint,
|
||||||
|
kpiPeriodId: kpiUserEvaluation.kpiPeriodId,
|
||||||
|
year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year,
|
||||||
|
durationKPI: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI,
|
||||||
|
}
|
||||||
|
return new HttpSuccess(mapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -286,6 +289,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
) {
|
) {
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
|
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||||
kpiPeriodId: kpiPeriodId,
|
kpiPeriodId: kpiPeriodId,
|
||||||
})
|
})
|
||||||
|
|
@ -318,6 +322,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
rolePoint: item.rolePoint,
|
rolePoint: item.rolePoint,
|
||||||
specialPoint: item.specialPoint,
|
specialPoint: item.specialPoint,
|
||||||
capacityPoint: item.capacityPoint,
|
capacityPoint: item.capacityPoint,
|
||||||
|
year: item.kpiPeriod ? item.kpiPeriod.year : null,
|
||||||
|
durationKPI: item.kpiPeriod ? item.kpiPeriod.durationKPI : null,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({ data: mapData, total });
|
return new HttpSuccess({ data: mapData, total });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,12 @@ export class KpiUserEvaluation extends EntityBase {
|
||||||
evaluationResults: string;
|
evaluationResults: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
comment: "คำขอแก้ไข",
|
comment: "คำขอแก้ไข",
|
||||||
default: false,
|
default: null,
|
||||||
})
|
})
|
||||||
isReqEdit: boolean;
|
evaluationReqEdit: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
type: "double",
|
type: "double",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableKpiUserEvaluationAddEvaluationReqEdit1715224977872 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableKpiUserEvaluationAddEvaluationReqEdit1715224977872'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`isReqEdit\` \`evaluationReqEdit\` tinyint NOT NULL COMMENT 'คำขอแก้ไข' DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationReqEdit\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationReqEdit\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationReqEdit\` tinyint NOT NULL COMMENT 'คำขอแก้ไข' DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`isReqEdit\` tinyint NOT NULL COMMENT 'คำขอแก้ไข' DEFAULT '0'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue