Merge branch 'develop' into develop-Bright
This commit is contained in:
commit
dbce13d107
3 changed files with 182 additions and 3 deletions
|
|
@ -796,14 +796,75 @@ export class ReportController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("report5")
|
||||
async report5() {
|
||||
async report5(
|
||||
@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")
|
||||
.leftJoinAndSelect("developmentScholarship.posLevelguarantor", "posLevelguarantor")
|
||||
.leftJoinAndSelect("developmentScholarship.posTypeguarantor", "posTypeguarantor")
|
||||
// .where("developmentScholarship.rootId = :rootId", { rootId: rootId })
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined
|
||||
? "developmentScholarship.scholarshipYear = :scholarshipYear"
|
||||
: "1=1",
|
||||
{ scholarshipYear: year },
|
||||
)
|
||||
.andWhere(
|
||||
"developmentScholarship.scholarshipType = :scholarshipType", { scholarshipType: "RESEARCH" },
|
||||
)
|
||||
.orderBy("developmentScholarship.scholarshipYear", "DESC")
|
||||
.addOrderBy("developmentScholarship.createdAt", "DESC")
|
||||
.getManyAndCount();
|
||||
|
||||
const totalBudgetApprove = development.reduce((sum, item) => sum + Number(item.budgetApprove), 0);
|
||||
const formattedData = development.map((item, index) => {
|
||||
const rawPath = [
|
||||
item.course == "-" ? null : item.course,
|
||||
item.field == "-" ? null : item.course
|
||||
];
|
||||
|
||||
const courseAndfield = rawPath
|
||||
.filter((path) => path !== undefined && path !== null)
|
||||
.join("/");
|
||||
|
||||
const date = [
|
||||
Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate)),
|
||||
Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))
|
||||
];
|
||||
|
||||
const dateDulation = date
|
||||
.filter((path) => path !== undefined && path !== null)
|
||||
.join(" - ");
|
||||
|
||||
return {
|
||||
no: Extension.ToThaiNumber((index + 1).toString()),
|
||||
id: item.id,
|
||||
studyTopic: item.studyTopic ? item.studyTopic : "-",
|
||||
fullName: item.prefix + item.firstName + " " + item.lastName,
|
||||
position: item.position,
|
||||
posLevel: item.posLevel ? item.posLevel.posLevelName : "-",
|
||||
courseAndfield: courseAndfield ?? "-",
|
||||
place: item.studyPlace ? item.studyPlace : "-",
|
||||
country: item.studyCountry ? item.studyCountry : "-",
|
||||
startAndendDate: dateDulation,
|
||||
budgetApprove: item.budgetApprove ? Extension.ToThaiNumber(item.budgetApprove.toString()) : "-",
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "reportFund5",
|
||||
reportName: "reportFund5",
|
||||
data: {
|
||||
data: "",
|
||||
year: Extension.ToThaiNumber(year.toString()),
|
||||
data: formattedData,
|
||||
total: Extension.ToThaiNumber(total.toString()),
|
||||
totalBudgetApprove: Extension.ToThaiNumber(totalBudgetApprove.toString()),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -814,8 +875,57 @@ export class ReportController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("report6")
|
||||
async report6() {
|
||||
async report6(
|
||||
@Query("year") year: number,
|
||||
) {
|
||||
const degree = [
|
||||
"ปริญญาเอก",
|
||||
"ปริญญาโท",
|
||||
"ปริญญาตรี",
|
||||
"ปวส.",
|
||||
"ปวช.",
|
||||
"ม.6",
|
||||
"ม.3",
|
||||
];
|
||||
|
||||
|
||||
// const totalBudgetApprove = development.reduce((sum, item) => sum + Number(item.budgetApprove), 0);
|
||||
// const formattedData = development.map((item, index) => {
|
||||
// const rawPath = [
|
||||
// item.course == "-" ? null : item.course,
|
||||
// item.field == "-" ? null : item.course
|
||||
// ];
|
||||
|
||||
// const courseAndfield = rawPath
|
||||
// .filter((path) => path !== undefined && path !== null)
|
||||
// .join("/");
|
||||
|
||||
// const date = [
|
||||
// Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate)),
|
||||
// Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))
|
||||
// ];
|
||||
|
||||
// const dateDulation = date
|
||||
// .filter((path) => path !== undefined && path !== null)
|
||||
// .join(" - ");
|
||||
|
||||
// return {
|
||||
// no: Extension.ToThaiNumber((index + 1).toString()),
|
||||
// id: item.id,
|
||||
// rootId: item.rootId,
|
||||
// root: item.root,
|
||||
// degree: item.degreeLevel,
|
||||
// // studyTopic: item.studyTopic ? item.studyTopic : "-",
|
||||
// // fullName: item.prefix + item.firstName + " " + item.lastName,
|
||||
// // position: item.position,
|
||||
// // posLevel: item.posLevel ? item.posLevel.posLevelName : "-",
|
||||
// // courseAndfield: courseAndfield ?? "-",
|
||||
// // place: item.studyPlace ? item.studyPlace : "-",
|
||||
// // country: item.studyCountry ? item.studyCountry : "-",
|
||||
// // startAndendDate: dateDulation,
|
||||
// // budgetApprove: item.budgetApprove ? Extension.ToThaiNumber(item.budgetApprove.toString()) : "-",
|
||||
// };
|
||||
// });
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "reportFund6",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue