浏览代码

新增指标

MaiXinRong 2 年之前
父节点
当前提交
75c1f58e0a
共有 3 个文件被更改,包括 30 次插入7 次删除
  1. 22 4
      app/service/report_memory.js
  2. 6 1
      app/service/stage_bills_pc.js
  3. 2 2
      sql/update.sql

+ 22 - 4
app/service/report_memory.js

@@ -410,9 +410,18 @@ module.exports = app => {
                 this.ctx.helper.assignRelaData(billsData, [
                     { data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'lid' },
                     { data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'], prefix: 'pre_', relaId: 'lid' },
-                    { data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp'], prefix: '', relaId: 'lid' },
-                    { data: endBpcStage, fields: ['end_contract_pc_tp', 'end_qc_pc_tp', 'end_pc_tp'], prefix: '', relaId: 'lid' },
+                    { data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp', 'org_price'], prefix: '', relaId: 'lid' },
+                    { data: endBpcStage, fields: ['end_contract_pc_tp', 'end_qc_pc_tp', 'end_pc_tp', 'org_price_his'], prefix: '', relaId: 'lid' },
                 ]);
+                billsData.forEach(x => {
+                    if (x.org_price_his && x.org_price_his.length > 0) {
+                        for (const prop of x.org_price_his) {
+                            x[`org_price_${prop}`] = x.org_price_his[prop];
+                        }
+                    } else {
+                        x.org_price_0 = x.unit_price;
+                    }
+                });
 
                 const billsTree = this._getNewBillsTree();
                 billsTree.loadDatas(billsData);
@@ -561,9 +570,18 @@ module.exports = app => {
 
                 this.ctx.helper.assignRelaData(billsData, [
                     {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'], prefix: 'pre_', relaId: 'lid'},
-                    { data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp'], prefix: '', relaId: 'lid' },
-                    { data: endBpcStage, fields: ['end_contract_pc_tp', 'end_qc_pc_tp', 'end_pc_tp'], prefix: '', relaId: 'lid' },
+                    { data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp', 'org_price'], prefix: '', relaId: 'lid' },
+                    { data: endBpcStage, fields: ['end_contract_pc_tp', 'end_qc_pc_tp', 'end_pc_tp', 'org_price_his'], prefix: '', relaId: 'lid' },
                 ]);
+                billsData.forEach(x => {
+                    if (x.org_price_his && x.org_price_his.length > 0) {
+                        for (const prop of x.org_price_his) {
+                            x[`org_price_${prop}`] = x.org_price_his[prop];
+                        }
+                    } else {
+                        x.org_price_0 = x.unit_price;
+                    }
+                });
                 const billsTree = this._getNewBillsTree();
                 billsTree.loadDatas(billsData);
 

+ 6 - 1
app/service/stage_bills_pc.js

@@ -46,9 +46,14 @@ module.exports = app => {
         }
 
         async getEndStageData(stage) {
-            const sql = 'SELECT lid, SUM(contract_pc_tp) AS end_contract_pc_tp, SUM(qc_pc_tp) AS end_qc_pc_tp, SUM(pc_tp) AS end_pc_tp, Sum(`positive_qc_pc_tp`) As `positive_qc_pc_tp`, Sum(`negative_qc_pc_tp`) As `negative_qc_pc_tp`' +
+            const sql = 'SELECT lid, SUM(contract_pc_tp) AS end_contract_pc_tp, SUM(qc_pc_tp) AS end_qc_pc_tp,' +
+                '    SUM(pc_tp) AS end_pc_tp, Sum(`positive_qc_pc_tp`) As `positive_qc_pc_tp`, Sum(`negative_qc_pc_tp`) As `negative_qc_pc_tp`,' +
+                '    GROUP_CONCAT(org_price) AS org_price_his' +
                 '  FROM ' + this.tableName + ' WHERE tid = ? and sorder <= ? GROUP BY lid';
             const result = await this.db.query(sql, [stage.tid, stage.order]);
+            result.forEach(r => {
+                r.org_price_his = r.org_price_his.split(',');
+            });
             return result;
         }
 

+ 2 - 2
sql/update.sql

@@ -482,10 +482,10 @@ ADD COLUMN `negative_qc_qty`  decimal(24,8) NOT NULL DEFAULT 0 AFTER `positive_q
 ALTER TABLE `zh_stage`
 ADD COLUMN `positive_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-正-变更金额' AFTER `his_id`,
 ADD COLUMN `pre_positive_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '截止上期-正-变更金额' AFTER `positive_qc_tp`,
-ADD COLUMN `positive_qc_pc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-正-变更金额' AFTER `pre_positive_qc_tp`,
+ADD COLUMN `positive_qc_pc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-正-变更补差金额' AFTER `pre_positive_qc_tp`,
 ADD COLUMN `negative_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-负-变更金额' AFTER `pre_positive_qc_tp`,
 ADD COLUMN `pre_negative_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '截止上期-负-变更金额' AFTER `negative_qc_tp`,
-ADD COLUMN `negative_qc_pc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-负-变更金额' AFTER `pre_negative_qc_tp`;
+ADD COLUMN `negative_qc_pc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-负-变更补差金额' AFTER `pre_negative_qc_tp`;
 
 ALTER TABLE `zh_stage_change`
 ADD COLUMN `unit_price`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '清单单价' AFTER `no_value`;