Merge branch 'develop' into adiDev
# Conflicts: # src/controllers/ReportController.ts
This commit is contained in:
commit
04e6b6fa7d
2 changed files with 33 additions and 7 deletions
|
|
@ -25,7 +25,10 @@ export class ReportController extends Controller {
|
|||
* @param {string} type type ประเภท report
|
||||
*/
|
||||
@Get("main")
|
||||
async GetReportDevelopemtMain(/*@Path() type: string*/) {
|
||||
async GetReportDevelopemtMain(
|
||||
@Query("year") year?: number,
|
||||
@Query("rootId") rootId?: string,
|
||||
) {
|
||||
|
||||
// const _type = type.trim().toUpperCase();
|
||||
const formattedData = {
|
||||
|
|
@ -565,7 +568,7 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report3")
|
||||
async report3(
|
||||
@Query("year") year: number,
|
||||
@Query("year") year?: number,
|
||||
@Query("rootId") rootId?: string,
|
||||
) {
|
||||
const developments = await AppDataSource.getRepository(DevelopmentScholarship)
|
||||
|
|
@ -651,7 +654,7 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report4")
|
||||
async report4(
|
||||
@Query("year") year: number,
|
||||
@Query("year") year?: number,
|
||||
) {
|
||||
const developments = await AppDataSource.getRepository(DevelopmentScholarship)
|
||||
.createQueryBuilder("developmentScholarship")
|
||||
|
|
@ -798,7 +801,7 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report5")
|
||||
async report5(
|
||||
@Query("year") year: number,
|
||||
@Query("year") year?: number,
|
||||
// @Query("rootId") rootId: string,
|
||||
) {
|
||||
|
||||
|
|
@ -862,7 +865,7 @@ export class ReportController extends Controller {
|
|||
template: "reportFund5",
|
||||
reportName: "reportFund5",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber((year+543).toString()),
|
||||
year: year?Extension.ToThaiNumber((year+543).toString()):"",
|
||||
data: formattedData,
|
||||
total: Extension.ToThaiNumber(total.toString()),
|
||||
totalBudgetApprove: Extension.ToThaiNumber(totalBudgetApprove.toString()),
|
||||
|
|
@ -877,7 +880,7 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report6")
|
||||
async report6(
|
||||
@Query("year") year: number,
|
||||
@Query("year") year?: number,
|
||||
) {
|
||||
const degree = [
|
||||
"ปริญญาเอก",
|
||||
|
|
@ -938,7 +941,7 @@ export class ReportController extends Controller {
|
|||
template: "reportFund6",
|
||||
reportName: "reportFund6",
|
||||
data: {
|
||||
year: Extension.ToThaiNumber((year+543).toString()),
|
||||
year: year?Extension.ToThaiNumber((year+543).toString()):"",
|
||||
data: "",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
23
src/migration/1739444714910-updateView.ts
Normal file
23
src/migration/1739444714910-updateView.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateView1739444714910 implements MigrationInterface {
|
||||
name = 'UpdateView1739444714910'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS 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\`
|
||||
`);
|
||||
await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]);
|
||||
await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue