Merge branch 'develop'
This commit is contained in:
commit
66805cdbfd
4 changed files with 90 additions and 1 deletions
|
|
@ -331,6 +331,8 @@ export class EvaluationController {
|
||||||
posNo: null,
|
posNo: null,
|
||||||
oc: null,
|
oc: null,
|
||||||
salary: null,
|
salary: null,
|
||||||
|
root: null,
|
||||||
|
orgRootId: null,
|
||||||
positionLevel: null,
|
positionLevel: null,
|
||||||
birthDate: null,
|
birthDate: null,
|
||||||
govAge: null,
|
govAge: null,
|
||||||
|
|
@ -2326,6 +2328,7 @@ export class EvaluationController {
|
||||||
"commanderPositionDoc2",
|
"commanderPositionDoc2",
|
||||||
"commanderAboveFullnameDoc2",
|
"commanderAboveFullnameDoc2",
|
||||||
"commanderAbovePositionDoc2",
|
"commanderAbovePositionDoc2",
|
||||||
|
"evaluationResult",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (!evaluation) {
|
if (!evaluation) {
|
||||||
|
|
@ -2359,6 +2362,7 @@ export class EvaluationController {
|
||||||
"commanderPositionDoc2",
|
"commanderPositionDoc2",
|
||||||
"commanderAboveFullnameDoc2",
|
"commanderAboveFullnameDoc2",
|
||||||
"commanderAbovePositionDoc2",
|
"commanderAbovePositionDoc2",
|
||||||
|
"evaluationResult",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (!evaluation) {
|
if (!evaluation) {
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,67 @@ export class ReoportController {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async sumaryEvaluationReport(@Query("year") year?: string, @Query("rootid") rootId?: string) {
|
async sumaryEvaluationReport(@Query("year") year?: string, @Query("rootid") rootId?: string) {
|
||||||
|
|
||||||
|
const yearInAD = year?year:null;
|
||||||
|
const yearInBE = yearInAD ? (parseInt(yearInAD) - 543).toString() : null;
|
||||||
|
|
||||||
|
const evaluation = await AppDataSource.getRepository(Evaluation)
|
||||||
|
.createQueryBuilder("evaluation")
|
||||||
|
.where('evaluation.evaluationResult NOT IN (:...evaluationResults)', { evaluationResults: ['PENDING'] })
|
||||||
|
.andWhere( yearInBE && yearInBE != null? 'YEAR(createdAt) = :year': "1=1", { year: yearInBE })
|
||||||
|
.andWhere(rootId?'orgRootId = :rootId': "1=1", { rootId: rootId })
|
||||||
|
.andWhere('evaluation.step = :step', { step: 'DONE' })
|
||||||
|
.getMany();
|
||||||
|
|
||||||
|
const groupedData = evaluation.reduce((acc:any, item) => {
|
||||||
|
const key = item.root;
|
||||||
|
if (!acc[key]) {
|
||||||
|
acc[key] = {
|
||||||
|
agency: item.root && item.root != "" ? item.root: "-",
|
||||||
|
submitter: 0,
|
||||||
|
passCount: 0,
|
||||||
|
notPassCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (item.evaluationResult === 'PASS') {
|
||||||
|
acc[key].passCount++;
|
||||||
|
} else if (item.evaluationResult === 'NOTPASS') {
|
||||||
|
acc[key].notPassCount++;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const result = Object.values(groupedData).map((item: any) => ({
|
||||||
|
...item ,
|
||||||
|
submitter: Extension.ToThaiNumber((item.passCount + item.notPassCount).toString()),
|
||||||
|
passCount: Extension.ToThaiNumber(item.passCount.toString()),
|
||||||
|
notPassCount: Extension.ToThaiNumber(item.notPassCount.toString()),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const submitter = Object.values(groupedData).reduce((acc: number, item: any) => {
|
||||||
|
return acc + item.passCount + item.notPassCount;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
const sumPass = Object.values(groupedData).reduce((acc: number, item: any) => {
|
||||||
|
return acc + item.passCount;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
const sumNotPass = Object.values(groupedData).reduce((acc: number, item: any) => {
|
||||||
|
return acc + item.notPassCount;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
template: "summary-evaluation",
|
template: "summary-evaluation",
|
||||||
reportName: "xlsx-report",
|
reportName: "xlsx-report",
|
||||||
data: null,
|
data: {
|
||||||
|
year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
|
||||||
|
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
|
||||||
|
mainAgency: rootId && result.length > 0?result[0].agency:"ทุกสำนักงานเขต",
|
||||||
|
list: result,
|
||||||
|
total: Extension.ToThaiNumber(submitter.toString()),
|
||||||
|
sumPass: Extension.ToThaiNumber(sumPass.toString()),
|
||||||
|
sumNotPass: Extension.ToThaiNumber(sumNotPass.toString()),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,12 @@ export class Evaluation extends EntityBase {
|
||||||
@Column({ nullable: true, comment: "สังกัด" })
|
@Column({ nullable: true, comment: "สังกัด" })
|
||||||
oc: string;
|
oc: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true, comment: "สำนักงานที่สังกัด" })
|
||||||
|
root: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true, length: 255, comment: "ไอดีสำนักงานที่สังกัด" })
|
||||||
|
orgRootId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "root",
|
comment: "root",
|
||||||
|
|
@ -294,6 +300,12 @@ export class CreateEvaluation {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
assessments?: CreateAssessment[];
|
assessments?: CreateAssessment[];
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
root?: string | null;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
orgRootId?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateEducation {
|
export class CreateEducation {
|
||||||
|
|
|
||||||
16
src/migration/1736140332359-update_eva_add_root.ts
Normal file
16
src/migration/1736140332359-update_eva_add_root.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateEvaAddRoot1736140332359 implements MigrationInterface {
|
||||||
|
name = 'UpdateEvaAddRoot1736140332359'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`root\` varchar(255) NULL COMMENT 'สำนักงานที่สังกัด'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`orgRootId\` varchar(255) NULL COMMENT 'ไอดีสำนักงานที่สังกัด'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`orgRootId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`root\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue