Browse Source

汇总表,计量单元,计算问题

MaiXinRong 2 years ago
parent
commit
a0e20cd97c
1 changed files with 18 additions and 2 deletions
  1. 18 2
      app/service/rpt_gather_memory.js

+ 18 - 2
app/service/rpt_gather_memory.js

@@ -358,7 +358,12 @@ module.exports = app => {
                 const l = this.ctx.helper._.find(billsData, {id: d.id});
                 this.ctx.helper._.assignIn(l, d);
             }
-            const pos = new Ledger.pos({ id: 'id', ledgerId: 'lid' });
+            const pos = new Ledger.pos({
+                id: 'id', ledgerId: 'lid',
+                calc: function (node) {
+                    node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
+                },
+            });
             const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tender.id} });
             let billsIndexData = {};
             for (const bd of billsData) {
@@ -390,6 +395,7 @@ module.exports = app => {
             billsTree.loadDatas(billsData);
             billsTree.calculateAll();
             pos.loadDatas(posData);
+            pos.calculateAll();
             this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
                 gatherUtils.gatherZone(tender, gatherNode, sourceNode, completeData.prefix, helper);
             }, function (gatherNode, sourceNode) {
@@ -441,7 +447,16 @@ module.exports = app => {
                 const l = this.ctx.helper._.find(billsData, {id: d.id});
                 this.ctx.helper._.assignIn(l, d);
             }
-            const pos = new Ledger.pos({ id: 'id', ledgerId: 'lid' });
+            const pos = new Ledger.pos({
+                id: 'id', ledgerId: 'lid',
+                calc: function (node) {
+                    node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
+                    node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
+                    node.end_contract_qty = helper.add(node.pre_contract_qty, node.contract_qty);
+                    node.end_qc_qty = helper.add(node.pre_qc_qty, node.qc_qty);
+                    node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
+                },
+            });
             const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tender.id } });
             if (stage) {
                 await this.ctx.service.stage.doCheckStage(stage);
@@ -468,6 +483,7 @@ module.exports = app => {
             billsTree.loadDatas(billsData);
             billsTree.calculateAll();
             pos.loadDatas(posData);
+            pos.calculateAll();
 
             this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
                 gatherUtils.gatherStage(tender, gatherNode, sourceNode, completeData.prefix, helper);