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")
|
@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({
|
return new HttpSuccess({
|
||||||
template: "reportFund5",
|
template: "reportFund5",
|
||||||
reportName: "reportFund5",
|
reportName: "reportFund5",
|
||||||
data: {
|
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")
|
@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({
|
return new HttpSuccess({
|
||||||
template: "reportFund6",
|
template: "reportFund6",
|
||||||
|
|
|
||||||
26
src/entities/view/viewDevScholarship.ts
Normal file
26
src/entities/view/viewDevScholarship.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
|
|
||||||
|
@ViewEntity({
|
||||||
|
expression: `SELECT MAX(\`rootId\`) AS rootId,
|
||||||
|
MAX(\`root\`) AS root,\`degreeLevel\`,
|
||||||
|
COUNT(*) AS numberOfRecords,
|
||||||
|
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
|
||||||
|
SUM(\`budgetApprove\`) AS totalBudgetApprove
|
||||||
|
FROM \`developmentScholarship\`
|
||||||
|
GROUP BY \`rootId\`,\`degreeLevel\`
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
|
||||||
|
export class viewProfileEvaluation {
|
||||||
|
@ViewColumn()
|
||||||
|
rootId: string;
|
||||||
|
@ViewColumn()
|
||||||
|
root: string;
|
||||||
|
@ViewColumn()
|
||||||
|
numberOfRecords: number;
|
||||||
|
@ViewColumn()
|
||||||
|
numberOfScholarshipTypes: number;
|
||||||
|
@ViewColumn()
|
||||||
|
totalBudgetApprove: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -30,6 +30,37 @@ class Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ToThaiShortMonth(value: number) {
|
||||||
|
switch (value) {
|
||||||
|
case 1:
|
||||||
|
return "ม.ค.";
|
||||||
|
case 2:
|
||||||
|
return "ก.พ.";
|
||||||
|
case 3:
|
||||||
|
return "มี.ค.";
|
||||||
|
case 4:
|
||||||
|
return "เม.ย.";
|
||||||
|
case 5:
|
||||||
|
return "พ.ค.";
|
||||||
|
case 6:
|
||||||
|
return "มิ.ย.";
|
||||||
|
case 7:
|
||||||
|
return "ก.ค.";
|
||||||
|
case 8:
|
||||||
|
return "ส.ค.";
|
||||||
|
case 9:
|
||||||
|
return "ก.ย.";
|
||||||
|
case 10:
|
||||||
|
return "ต.ค.";
|
||||||
|
case 11:
|
||||||
|
return "พ.ย.";
|
||||||
|
case 12:
|
||||||
|
return "ธ.ค.";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ToThaiYear(value: number) {
|
public static ToThaiYear(value: number) {
|
||||||
if (value < 2400) return value + 543;
|
if (value < 2400) return value + 543;
|
||||||
else return value;
|
else return value;
|
||||||
|
|
@ -86,6 +117,18 @@ class Extension {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ToThaiShortDate(value: Date) {
|
||||||
|
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||||
|
return (
|
||||||
|
value.getDate() +
|
||||||
|
" " +
|
||||||
|
Extension.ToThaiShortMonth(value.getMonth() + 1) +
|
||||||
|
" " +
|
||||||
|
yy.toString().slice(-2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Extension;
|
export default Extension;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue