Merge branch 'develop' into adiDev
This commit is contained in:
commit
3d7b32abbd
1 changed files with 55 additions and 23 deletions
|
|
@ -567,34 +567,66 @@ export class ReportController extends Controller {
|
|||
@Query("year") year: number,
|
||||
@Query("rootId") rootId?: string,
|
||||
) {
|
||||
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
|
||||
.createQueryBuilder("developmentScholarship")
|
||||
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("developmentScholarship.posType", "posType")
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined
|
||||
? "developmentScholarship.scholarshipYear = :scholarshipYear"
|
||||
: "1=1",
|
||||
{ scholarshipYear: year },
|
||||
)
|
||||
.andWhere(
|
||||
rootId != "" && rootId != null && rootId != undefined
|
||||
? "developmentScholarship.rootId = :rootId"
|
||||
: "1=1",
|
||||
{ rootId: rootId },
|
||||
)
|
||||
.orderBy("developmentScholarship.scholarshipYear", "DESC")
|
||||
.addOrderBy("developmentScholarship.createdAt", "DESC")
|
||||
.getManyAndCount();
|
||||
const developments = await AppDataSource.getRepository(DevelopmentScholarship)
|
||||
.createQueryBuilder("developmentScholarship")
|
||||
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("developmentScholarship.posType", "posType")
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined
|
||||
? "developmentScholarship.scholarshipYear = :scholarshipYear"
|
||||
: "1=1",
|
||||
{ scholarshipYear: year },
|
||||
)
|
||||
.andWhere(
|
||||
rootId != "" && rootId != null && rootId != undefined
|
||||
? "developmentScholarship.rootId = :rootId"
|
||||
: "1=1",
|
||||
{ rootId: rootId },
|
||||
)
|
||||
.orderBy("developmentScholarship.scholarshipYear", "DESC")
|
||||
.addOrderBy("developmentScholarship.createdAt", "DESC")
|
||||
.getMany();
|
||||
|
||||
const mapData = developments.map((item, idx:number) => ({
|
||||
no: Extension.ToThaiNumber((idx+1).toString()),
|
||||
institution: item.educationalInstitution ? item.educationalInstitution : "-",
|
||||
scholarshipType: item.scholarshipType ? item.scholarshipType : "-",
|
||||
degreeLevel: item.degreeLevel ? item.degreeLevel : "-",
|
||||
course: item.course ? item.course : "-",
|
||||
field: item.field ? item.field : "-",
|
||||
fullName: `${item.prefix}${item.firstName} ${item.lastName}`,
|
||||
position: item.position ? item.position : "-",
|
||||
posLevel: item.posLevel ? item.posLevel.posLevelName : "-",
|
||||
totalPeriod: item.totalPeriod ? item.totalPeriod : "-",
|
||||
budgetApprove: item.budgetApprove ? Extension.ToThaiNumber(item.budgetApprove.toString()) : "๐" //toLocaleString
|
||||
}));
|
||||
|
||||
const sum = developments
|
||||
.filter(x => x.budgetApprove)
|
||||
.reduce((acc, item) => acc + (Number(item.budgetApprove)), 0);
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "reportFund3",
|
||||
reportName: "reportFund3",
|
||||
data: {
|
||||
year: year ? Extension.ToThaiNumber(year.toString()) : "-",
|
||||
root: null,
|
||||
developments: development,
|
||||
total: total
|
||||
year: year ? Extension.ToThaiNumber((year+543).toString()) : "-",
|
||||
root: developments.length > 0 ? developments[0].root : "-",
|
||||
data: mapData.length > 0
|
||||
? mapData
|
||||
: [{
|
||||
no: "-",
|
||||
institution: "-",
|
||||
scholarshipType: "-",
|
||||
degreeLevel: "-",
|
||||
course: "-",
|
||||
field: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevel: "-",
|
||||
totalPeriod: "-",
|
||||
budgetApprove: "-",
|
||||
}],
|
||||
sum: sum ? Extension.ToThaiNumber(sum.toString()): "-"
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue