Explorar el Código

中间计量,报表相关

MaiXinRong hace 5 años
padre
commit
b71e021b87
Se han modificado 2 ficheros con 18 adiciones y 17 borrados
  1. 11 10
      app/lib/stage_im.js
  2. 7 7
      app/service/report_memory.js

+ 11 - 10
app/lib/stage_im.js

@@ -441,20 +441,21 @@ class StageIm {
     }
 
     _addBwBillsGclBills(im, bills) {
+        const helper = this.ctx.helper;
         if (!im.gclBills) im.gclBills = [];
         let gcl = im.gclBills.find(function (x) {
             return (!bills.b_code || bills.b_code === x.b_code) &&
                 (!bills.name || bills.name === x.name) &&
                 (!bills.unit || bills.unit === x.unit) &&
-                checkZero(this.ctx.helper.sub(bills.unit_price, x.unit_price));
+                helper.checkZero(helper.sub(bills.unit_price, x.unit_price));
         });
         if (!gcl) {
             gcl = {b_code: bills.b_code, name: bills.name, unit: bills.unit, unit_price: bills.unit_price};
             im.gclBills.push(gcl);
         }
-        gcl.contract_jl = this.ctx.helper.add(gcl.contract_jl, bills.contract_jl);
-        gcl.qc_jl = this.ctx.helper.add(gcl.qc_jl, bills.qc_jl);
-        gcl.jl = this.ctx.helper.add(gcl.jl, bills.jl);
+        gcl.contract_jl = helper.add(gcl.contract_jl, bills.contract_jl);
+        gcl.qc_jl = helper.add(gcl.qc_jl, bills.qc_jl);
+        gcl.jl = helper.add(gcl.jl, bills.jl);
     }
     _calculateBwBillsIm(im) {
         const tp_decimal = this.ctx.tender.info.decimal.tp;
@@ -501,9 +502,9 @@ class StageIm {
     _generateBwBillsImData (node) {
         if (!node.gather_tp && !node.contract_tp && !node.qc_tp) return;
 
-        const nodeIndex = gsTree.getNodeIndex(node);
+        const nodeIndex = this.billsTree.getNodeSerialNo(node);
         const peg = this._getPegNode(node);
-        const nodeImData = [], posterity = gsTree.getPosterity(node);
+        const nodeImData = [], posterity = this.billsTree.getPosterity(node);
         const bw = this._getBwBillsBw(node);
         const imDefault = this._getBwBillsIm(node, peg, nodeIndex, bw);
         for (const p of posterity) {
@@ -523,7 +524,7 @@ class StageIm {
                         jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
                     });
 
-                    for (const c of changes) {
+                    for (const c of this.changes) {
                         if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
                             im.changes.push(c);
                         }
@@ -533,7 +534,7 @@ class StageIm {
                     if (pp.position && im.position instanceof Array) im.position.push(pp.position);
                 }
             } else {
-                for (const c of changes) {
+                for (const c of this.changes) {
                     if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {
                         imDefault.changes.push(c);
                     }
@@ -550,13 +551,13 @@ class StageIm {
         }
         if (imDefault.contract_jl || imDefault.qc_jl) {
             imDefault.jl = this.ctx.helper.add(imDefault.contract_jl, imDefault.qc_jl);
-            ImData.push(imDefault);
+            this.ImData.push(imDefault);
         }
         for (const im of nodeImData) {
             this._calculateBwBillsIm(im);
             im.drawing_code = this.ctx.helper._.uniq(im.drawing_code).join(mergeChar);
             im.position = this.ctx.helper._.uniq(im.position).join(mergeChar);
-            ImData.push(im);
+            this.ImData.push(im);
         }
     }
 

+ 7 - 7
app/service/report_memory.js

@@ -177,9 +177,9 @@ module.exports = app => {
         }
 
         async _generateStageIm(tid, sid, isTz = true) {
-            if (isTz && [imType.tz.value, imType.bb.value].indexOf(this.ctx.stage.im_type) >= 0) {
+            if (isTz && [imType.tz.value, imType.bb.value].indexOf(this.ctx.stage.im_type) === -1) {
                 throw '您查看的报表跟设置不符,请查看“总量控制”的报表';
-            } else if (!isTz && [imType.zl.value, imType.bw.value].indexOf(this.ctx.stage.im_type) >= 0) {
+            } else if (!isTz && [imType.zl.value, imType.bw.value].indexOf(this.ctx.stage.im_type) === -1) {
                 throw '您查看的报表跟设置不符,请查看“0号台账”的报表';
             }
             const stageIm = new StageIm(this.ctx);
@@ -208,10 +208,10 @@ module.exports = app => {
                 try {
                     await this._generateStageIm(tid, sid);
                 } catch (err) {
-                    if (err.statck) {
+                    if (err.stack) {
                         this.ctx.logger.error(err);
                     }
-                    this.stageImData.main = err.statck ? '数据错误' : err;
+                    this.stageImData.main = err.stack ? '数据错误' : err;
                     this.stageImData.bills = this.stageImData.main;
                 }
             }
@@ -231,10 +231,10 @@ module.exports = app => {
                 try {
                     await this._generateStageIm(tid, sid);
                 } catch (err) {
-                    if (err.statck) {
+                    if (err.stack) {
                         this.ctx.logger.error(err);
                     }
-                    this.stageImData.main = err.statck ? '数据错误' : err;
+                    this.stageImData.main = err.stack ? '数据错误' : err;
                     this.stageImData.bills = this.stageImData.main;
                 }
             }
@@ -253,7 +253,7 @@ module.exports = app => {
             try {
                 await this._generateStageIm(tid, sid, false);
             } catch (err) {
-                if (err.statck) {
+                if (err.stack) {
                     this.ctx.logger.error(err);
                 }
                 this.stageImData.main = err.statck ? '数据错误' : err;