Sfoglia il codice sorgente

导入变更计量,基础数据获取调整

MaiXinRong 3 anni fa
parent
commit
86a995de5d
3 ha cambiato i file con 17 aggiunte e 4 eliminazioni
  1. 5 1
      app/lib/sum_load.js
  2. 10 0
      app/service/stage_change.js
  3. 2 3
      app/service/stage_change_final.js

+ 5 - 1
app/lib/sum_load.js

@@ -8,6 +8,7 @@
  * @version
  */
 const Ledger = require('../lib/ledger');
+const auditConst = require('../const/audit');
 
 class loadGclBaseTree {
     /**
@@ -538,7 +539,10 @@ class sumLoad {
             const stage = await this.ctx.service.stage.getDataByCondition({tid: tender.tid, order: tender.stage});
             if (!stage) throw '选择的期不存在';
             const curStageData = await this.ctx.service.stageBills.getLastestStageData2(tender.tid, stage.id);
-            const curStageChange = await this.ctx.service.stageChangeFinal.getSumLoadFinalData(stage.id);
+            const curStageChange = stage.status === auditConst.stage.status.checked
+                ? await this.ctx.service.stageChangeFinal.getSumLoadFinalData(stage.id)
+                : await this.ctx.service.stageChange.getSumLoadFinalData(stage.id);
+            console.log(curStageChange);
             this._loadCurStageAndChange(billsData, curStageData, curStageChange);
             const billsTree = new Ledger.billsTree(this.ctx, {
                 id: 'ledger_id',

+ 10 - 0
app/service/stage_change.js

@@ -374,6 +374,16 @@ module.exports = app => {
             return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
         }
 
+        async getSumLoadFinalData(sid) {
+            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.cid, cf.cbid, cf.qty, c.code As c_code' +
+                '  FROM ' + this.tableName + ' cf' +
+                '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
+                '  Where cf.sid = ?';
+            const result = await this.db.query(sql, [sid]);
+            console.log(this.db.format(sql, [sid]));
+            return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
+        }
+
         async _getTender(stage) {
             if (this.ctx.tender) return this.ctx.tender;
             const tender = { id: stage.tid };

+ 2 - 3
app/service/stage_change_final.js

@@ -84,11 +84,10 @@ module.exports = app => {
         }
 
         async getSumLoadFinalData(sid) {
-            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.cid, cf.cbid, sum(cf.qty) as qty, c.code As c_code' +
+            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.cid, cf.cbid, cf.qty, c.code As c_code' +
                 '  FROM ' + this.tableName + ' cf' +
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
-                '  Where cf.sid = ?' +
-                '  Group By cf.lid, cf.cbid';
+                '  Where cf.sid = ?';
             return await this.db.query(sql, [sid]);
         }
     }