瀏覽代碼

加载台账历史数据时,加载最新的总额计量、三方数据等

MaiXinRong 3 年之前
父節點
當前提交
5cb2483350
共有 3 個文件被更改,包括 27 次插入3 次删除
  1. 3 3
      app/controller/stage_controller.js
  2. 12 0
      app/service/ledger.js
  3. 12 0
      app/service/pos.js

+ 3 - 3
app/controller/stage_controller.js

@@ -249,7 +249,7 @@ module.exports = app => {
             //     ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
             //     ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
             //     : await ctx.service.ledger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
             //     : await ctx.service.ledger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
             const ledgerData = ctx.stage.ledgerHis
             const ledgerData = ctx.stage.ledgerHis
-                ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
+                ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
                 : await ctx.service.ledger.getAllDataByCondition({ columns: ledgerColumn, where: { tender_id: ctx.tender.id } });
                 : await ctx.service.ledger.getAllDataByCondition({ columns: ledgerColumn, where: { tender_id: ctx.tender.id } });
             const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
             const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
             for (const d of dgnData) {
             for (const d of dgnData) {
@@ -1359,10 +1359,10 @@ module.exports = app => {
                 if (data.main) {
                 if (data.main) {
                     result.main = {};
                     result.main = {};
                     result.main.ledger = ctx.stage.ledgerHis
                     result.main.ledger = ctx.stage.ledgerHis
-                        ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
+                        ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
                         : await ctx.service.ledger.getData(ctx.tender.id);
                         : await ctx.service.ledger.getData(ctx.tender.id);
                     result.main.pos = ctx.stage.ledgerHis
                     result.main.pos = ctx.stage.ledgerHis
-                        ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.pos_file)
+                        ? await ctx.service.pos.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
                         : await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                         : await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                 }
                 }
                 for (const order of data.roles) {
                 for (const order of data.roles) {

+ 12 - 0
app/service/ledger.js

@@ -757,6 +757,18 @@ module.exports = app => {
                 throw (err.stack ? '导入工程量数据出错': err);
                 throw (err.stack ? '导入工程量数据出错': err);
             }
             }
         }
         }
+
+        async loadDataFromOss(tid, url) {
+            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
+            const curData = await this.getAllDataByCondition({
+                columns: ['id', 'is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
+                where: { tender_id: tid }
+            });
+            this.ctx.helper.assignRelaData(data, [
+                { data: curData, fields: ['is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
+            ]);
+            return data;
+        }
     }
     }
 
 
     return Ledger;
     return Ledger;

+ 12 - 0
app/service/pos.js

@@ -503,6 +503,18 @@ module.exports = app => {
         async deletePosData(transaction, tid, lid) {
         async deletePosData(transaction, tid, lid) {
             await transaction.delete(this.tableName, {tid: tid, lid: lid});
             await transaction.delete(this.tableName, {tid: tid, lid: lid});
         }
         }
+
+        async loadDataFromOss(tid, url) {
+            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
+            const curData = await this.getAllDataByCondition({
+                columns: ['id', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
+                where: { tid: tid }
+            });
+            this.ctx.helper.assignRelaData(data, [
+                { data: curData, fields: ['gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
+            ]);
+            return data;
+        }
     }
     }
 
 
     return Pos;
     return Pos;