Procházet zdrojové kódy

报表,提供投资进度数据

MaiXinRong před 1 rokem
rodič
revize
ba1b2175e1

+ 8 - 2
app/service/report.js

@@ -42,7 +42,6 @@ module.exports = app => {
             }
         }
 
-
         getFilter(sourceFilters) {
             const common = [], spec = [];
             for (const sf of sourceFilters) {
@@ -387,7 +386,14 @@ module.exports = app => {
                             runnableKey.push(filter);
                             break;
                         case 'mem_schedule_month':
-                            runnableRst.push(service.scheduleMonth.getAllDataByCondition({ where: { tid: params.tender_id }, orders: [['yearmonth', 'asc']] }));
+                            runnableRst.push(service.scheduleMonth.getReportData(params.tender_id));
+                            runnableKey.push(filter);
+                            break;
+                        case 'mem_schedule_stage':
+                            runnableRst.push(service.scheduleStage.getReportData(params.tender_id));
+                            runnableKey.push(filter);
+                        case 'mem_schedule':
+                            runnableRst.push(service.schedule.getDataByCondition({ tid: params.tender_id }));
                             runnableKey.push(filter);
                             break;
                         default:

+ 5 - 0
app/service/schedule_month.js

@@ -107,6 +107,11 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async getReportData(tid) {
+            const sql = `SELECT *, (@sum := @sum + plan_tp) as sum_plan_tp FROM ${this.tableName}, (SELECT @SUM := 0)T where tid = ? ORDER BY yearmonth;`;
+            return await this.db.query(sql, [tid]);
+        }
     }
     return ScheduleMonth;
 };

+ 5 - 0
app/service/schedule_stage.js

@@ -132,6 +132,11 @@ module.exports = app => {
             };
             await transaction.update(this.ctx.service.schedule.tableName, stageData, stageOption);
         }
+
+        async getReportData(tid) {
+            const sql = `SELECT *, (@sum := @sum + tp) as sum_tp FROM ${this.tableName}, (SELECT @SUM := 0)T where tid = ? ORDER BY yearmonth;`;
+            return await this.db.query(sql, [tid]);
+        }
     }
     return ScheduleStage;
 };