diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 63a5328..5b1fd4c 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -59,6 +59,15 @@ export class ReoportController { */ @Get() async sumaryEvaluationReport(@Query("year") year?: string, @Query("rootid") rootId?: string) { + + const yearInAD = year?year:null; + + const evaluation = await AppDataSource.getRepository(Evaluation) + .createQueryBuilder("evaluation") + .where( yearInAD && yearInAD != null? 'YEAR(createdAt) = :year': "1=1", { year: yearInAD }) + .andWhere(rootId?'orgRootId = :rootId': "1=1", { rootId: rootId }) + .getMany(); + return new HttpSuccess({ template: "summary-evaluation", reportName: "xlsx-report", diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 5aa0945..5c5f12d 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -33,6 +33,12 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "สังกัด" }) oc: string; + @Column({ nullable: true, comment: "สำนักงานที่สังกัด" }) + root: string; + + @Column({ nullable: true, length: 255, comment: "ไอดีสำนักงานที่สังกัด" }) + orgRootId: string; + @Column({ nullable: true, comment: "root", @@ -294,6 +300,12 @@ export class CreateEvaluation { @Column() assessments?: CreateAssessment[]; + + @Column() + root?: string | null; + + @Column() + orgRootId?: string | null; } export class CreateEducation {