Merge branch 'develop' of https://github.com/Frappet/bma-ehr-kpi into develop

This commit is contained in:
AnandaTon 2024-05-08 14:28:02 +07:00
commit 94fddd1743
5 changed files with 85 additions and 32 deletions

View file

@ -340,8 +340,10 @@ export class kpiPlanController extends Controller {
} }
const formattedData = { const formattedData = {
id: kpiPlan.id, id: kpiPlan.id,
year: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.year, // year: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.year,
round: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.durationKPI, // round: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.durationKPI,
year: kpiPlan.year == null ? null : kpiPlan.year,
round: kpiPlan.period == null ? null : kpiPlan.period,
kpiPeriodId: kpiPlan.kpiPeriodId, kpiPeriodId: kpiPlan.kpiPeriodId,
including: kpiPlan.including, including: kpiPlan.including,
includingName: kpiPlan.includingName, includingName: kpiPlan.includingName,
@ -372,6 +374,7 @@ export class kpiPlanController extends Controller {
strategyChild3: kpiPlan.strategyChild3Id, strategyChild3: kpiPlan.strategyChild3Id,
strategyChild4: kpiPlan.strategyChild4Id, strategyChild4: kpiPlan.strategyChild4Id,
strategyChild5: kpiPlan.strategyChild5Id, strategyChild5: kpiPlan.strategyChild5Id,
documentInfoEvidence: kpiPlan.documentInfoEvidence,
}; };
return new HttpSuccess(formattedData); return new HttpSuccess(formattedData);
} }
@ -392,9 +395,9 @@ export class kpiPlanController extends Controller {
period?: string | null; period?: string | null;
nodeId?: string | null; nodeId?: string | null;
node?: number | null; node?: number | null;
keyword?: string; keyword?: string | null;
isAll?: boolean; isAll?: boolean | false;
isNull?: boolean; // isNull?: boolean | false;
}, },
) { ) {
let condition = ""; let condition = "";
@ -442,21 +445,37 @@ export class kpiPlanController extends Controller {
} }
parameters.nodeId = `%${requestBody.nodeId}%`; parameters.nodeId = `%${requestBody.nodeId}%`;
} }
if (requestBody.year && requestBody.period && requestBody.isNull === true) { // 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)`; // 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.year = `%${requestBody.year}%`;
parameters.period = `%${requestBody.period}%`; // 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(
// requestBody.year && requestBody.period
// ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period"
// : "1=1",
// {
// year: `%${requestBody.year}%`,
// period: `%${requestBody.period}%`,
// },
// )
.andWhere( .andWhere(
requestBody.isNull === false && requestBody.year && requestBody.period requestBody.year
? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period" ? "kpiPlan.year LIKE :year"
: "1=1", : "1=1",
{ {
year: `%${requestBody.year}%`, year: `%${requestBody.year}%`,
},
)
.andWhere(
requestBody.period
? "kpiPlan.period LIKE :period"
: "1=1",
{
period: `%${requestBody.period}%`, period: `%${requestBody.period}%`,
}, },
) )

View file

@ -296,8 +296,10 @@ export class kpiRoleController extends Controller {
} }
const formattedData = { const formattedData = {
id: kpiRole.id, id: kpiRole.id,
year: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.year, // year: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.year,
round: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.durationKPI, // round: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.durationKPI,
year: kpiRole.year == null ? null : kpiRole.year,
round: kpiRole.period == null ? null : kpiRole.period,
kpiPeriodId: kpiRole.kpiPeriodId, kpiPeriodId: kpiRole.kpiPeriodId,
including: kpiRole.including, including: kpiRole.including,
includingName: kpiRole.includingName, includingName: kpiRole.includingName,
@ -321,6 +323,8 @@ export class kpiRoleController extends Controller {
nodeName: nodeName, nodeName: nodeName,
orgRevisionId: kpiRole.orgRevisionId, orgRevisionId: kpiRole.orgRevisionId,
position: kpiRole.position, position: kpiRole.position,
documentInfoEvidence: kpiRole.documentInfoEvidence,
}; };
return new HttpSuccess(formattedData); return new HttpSuccess(formattedData);
} }
@ -342,9 +346,9 @@ export class kpiRoleController extends Controller {
nodeId?: string | null; nodeId?: string | null;
node?: number | null; node?: number | null;
position?: string | null; position?: string | null;
keyword?: string; keyword?: string | null;
isAll?: boolean; isAll?: boolean | false;
isNull?: boolean; // isNull?: boolean | false;
}, },
) { ) {
let condition = ""; let condition = "";
@ -392,11 +396,11 @@ export class kpiRoleController extends Controller {
} }
parameters.nodeId = `%${requestBody.nodeId}%`; parameters.nodeId = `%${requestBody.nodeId}%`;
} }
if (requestBody.year && requestBody.period && requestBody.isNull === true) { // if (requestBody.year && requestBody.period && requestBody.isNull === true) {
condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`; // condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`;
parameters.year = `%${requestBody.year}%`; // parameters.year = `%${requestBody.year}%`;
parameters.period = `%${requestBody.period}%`; // parameters.period = `%${requestBody.period}%`;
} // }
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole) const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
.createQueryBuilder("kpiRole") .createQueryBuilder("kpiRole")
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod") .leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
@ -416,15 +420,31 @@ export class kpiRoleController extends Controller {
nodeId: requestBody.nodeId, nodeId: requestBody.nodeId,
}, },
) )
// .andWhere(
// requestBody.year && requestBody.period
// ? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period"
// : "1=1",
// {
// year: `%${requestBody.year}%`,
// period: `%${requestBody.period}%`,
// },
// )
.andWhere( .andWhere(
requestBody.isNull === false && requestBody.year && requestBody.period requestBody.year
? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period" ? "kpiRole.year LIKE :year"
: "1=1", : "1=1",
{ {
year: `%${requestBody.year}%`, year: `%${requestBody.year}%`,
period: `%${requestBody.period}%`, },
}, )
) .andWhere(
requestBody.period
? "kpiRole.period LIKE :period"
: "1=1",
{
period: `%${requestBody.period}%`,
},
)
.andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", { .andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
}) })

View file

@ -127,7 +127,7 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.lastName = x.lastName; kpiUserEvaluation.lastName = x.lastName;
}) })
.catch((x) => {}); .catch((x) => {});
kpiUserEvaluation.evaluationStatus = "PENDING"; kpiUserEvaluation.evaluationStatus = "NEW";
kpiUserEvaluation.evaluationResults = "PENDING"; kpiUserEvaluation.evaluationResults = "PENDING";
kpiUserEvaluation.createdUserId = request.user.sub; kpiUserEvaluation.createdUserId = request.user.sub;
kpiUserEvaluation.createdFullName = request.user.name; kpiUserEvaluation.createdFullName = request.user.name;

View file

@ -71,7 +71,7 @@ export class KpiUserEvaluation extends EntityBase {
length: 40, length: 40,
comment: comment:
"สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น", "สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
default: null, default: "NEW",
}) })
evaluationStatus: string; evaluationStatus: string;

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableKpiDevelopment11715151729330 implements MigrationInterface {
name = 'AddTableKpiDevelopment11715151729330'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น' DEFAULT 'NEW'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น'`);
}
}