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> },
|
||||
) {
|
||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
including: String(requestBody.including),
|
||||
includingName: String(requestBody.includingName),
|
||||
},
|
||||
});
|
||||
if(chk_kpiSpecial){
|
||||
if (chk_kpiSpecial) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
|
|
@ -88,13 +88,13 @@ export class kpiSpecialController extends Controller {
|
|||
}
|
||||
|
||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
id: Not(id),
|
||||
including: String(requestBody.including),
|
||||
includingName: String(requestBody.includingName),
|
||||
},
|
||||
});
|
||||
if(chk_kpiSpecial){
|
||||
if (chk_kpiSpecial) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||
|
|
@ -114,7 +114,7 @@ export class kpiSpecialController extends Controller {
|
|||
@Get("{id}")
|
||||
async GetKpiSpecialById(@Path() id: string) {
|
||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id }
|
||||
where: { id: id },
|
||||
});
|
||||
if (!KpiSpecial) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัด Specialนี้");
|
||||
|
|
@ -151,50 +151,61 @@ export class kpiSpecialController extends Controller {
|
|||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Get()
|
||||
@Post("search")
|
||||
async listKpiSpecial(
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
year?: string | null;
|
||||
period?: string | null;
|
||||
keyword?: string | null;
|
||||
},
|
||||
) {
|
||||
let whereClause: any = {};
|
||||
if (keyword !== undefined && keyword !== "") {
|
||||
whereClause = {
|
||||
where: [{
|
||||
including: Like(`%${keyword}%`),
|
||||
includingName: Like(`%${keyword}%`),
|
||||
}],
|
||||
let condition: any = {};
|
||||
if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
||||
condition = {
|
||||
where: [
|
||||
{
|
||||
including: Like(`%${requestBody.keyword}%`),
|
||||
includingName: Like(`%${requestBody.keyword}%`),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const [kpiSpecial, total] = await this.kpiSpecialRepository.findAndCount({
|
||||
...whereClause,
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const mapData = kpiSpecial.map((KpiSpecial) => ({
|
||||
id: KpiSpecial.id,
|
||||
period: KpiSpecial.period,
|
||||
year: KpiSpecial.year,
|
||||
including: KpiSpecial.including,
|
||||
includingName: KpiSpecial.includingName,
|
||||
target: KpiSpecial.target,
|
||||
unit: KpiSpecial.unit,
|
||||
weight: KpiSpecial.weight,
|
||||
point: KpiSpecial.point,
|
||||
summary: KpiSpecial.summary,
|
||||
documentInfoEvidence: KpiSpecial.documentInfoEvidence,
|
||||
startDate: KpiSpecial.startDate,
|
||||
endDate: KpiSpecial.endDate,
|
||||
achievement1: KpiSpecial.achievement1,
|
||||
achievement2: KpiSpecial.achievement2,
|
||||
achievement3: KpiSpecial.achievement3,
|
||||
achievement4: KpiSpecial.achievement4,
|
||||
achievement5: KpiSpecial.achievement5,
|
||||
meaning: KpiSpecial.meaning,
|
||||
formula: KpiSpecial.formula,
|
||||
}));
|
||||
return new HttpSuccess({ data: mapData, total });
|
||||
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
|
||||
.createQueryBuilder("kpiSpecial")
|
||||
.andWhere(condition)
|
||||
.andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", {
|
||||
year: `%${requestBody.year}%`,
|
||||
})
|
||||
.andWhere(requestBody.period ? "kpiSpecial.period LIKE :period" : "1=1", {
|
||||
period: `%${requestBody.period}%`,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiSpecial.including LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
}).orWhere("kpiSpecial.includingName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.select([
|
||||
"kpiSpecial.id",
|
||||
"kpiSpecial.year",
|
||||
"kpiSpecial.period",
|
||||
"kpiSpecial.including",
|
||||
"kpiSpecial.includingName",
|
||||
"kpiSpecial.createdAt",
|
||||
])
|
||||
.orderBy("kpiSpecial.createdAt", "DESC")
|
||||
.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}")
|
||||
async GetKpiUserEvaluationById(@Path() id: string) {
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
relations:["kpiPeriod"],
|
||||
where: { id: id },
|
||||
select: [
|
||||
"id",
|
||||
"profileId",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"kpiPeriodId",
|
||||
"evaluationStatus",
|
||||
"evaluationResults",
|
||||
"createdAt",
|
||||
"evaluatorId",
|
||||
"commanderId",
|
||||
"commanderHighId",
|
||||
"plannedPoint",
|
||||
"rolePoint",
|
||||
"specialPoint",
|
||||
"capacityPoint",
|
||||
],
|
||||
});
|
||||
if (!kpiUserEvaluation) {
|
||||
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)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||
kpiPeriodId: kpiPeriodId,
|
||||
})
|
||||
|
|
@ -318,6 +322,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
rolePoint: item.rolePoint,
|
||||
specialPoint: item.specialPoint,
|
||||
capacityPoint: item.capacityPoint,
|
||||
year: item.kpiPeriod ? item.kpiPeriod.year : null,
|
||||
durationKPI: item.kpiPeriod ? item.kpiPeriod.durationKPI : null,
|
||||
}));
|
||||
return new HttpSuccess({ data: mapData, total });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,10 +85,12 @@ export class KpiUserEvaluation extends EntityBase {
|
|||
evaluationResults: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คำขอแก้ไข",
|
||||
default: false,
|
||||
default: null,
|
||||
})
|
||||
isReqEdit: boolean;
|
||||
evaluationReqEdit: string;
|
||||
|
||||
@Column({
|
||||
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