Przeglądaj źródła

优化材差数据获取

MaiXinRong 2 lat temu
rodzic
commit
4060be70fe
2 zmienionych plików z 22 dodań i 3 usunięć
  1. 18 2
      app/lib/rm/material.js
  2. 4 1
      sql/update.sql

+ 18 - 2
app/lib/rm/material.js

@@ -285,7 +285,13 @@ class ReportMemoryMaterial {
 
     async _getMaterialStageGatherBills(tender_id, stage_id, stage_order, stageSelf) {
         const decimal = this.materialGatherBase.decimal;
-        const billsData = this.ctx.helper.clone(this.materialGatherBase.billsData);
+        //const billsData = this.ctx.helper.clone(this.materialGatherBase.billsData);
+        const billsData = this.materialGatherBase.billsData;
+        billsData.forEach(x => {
+            for (const prop of ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp']) {
+                x[prop] = undefined;
+            }
+        });
         const curStageBills = await this.ctx.service.stageBills.getStagesData(tender_id, stage_id);
         this.ctx.helper.assignRelaData(billsData, [
             { data: curStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
@@ -294,7 +300,13 @@ class ReportMemoryMaterial {
         billsTree.loadDatas(billsData);
         billsTree.calculateAll();
 
-        const posData = this.ctx.helper.clone(this.materialGatherBase.posData);
+        //const posData = this.ctx.helper.clone(this.materialGatherBase.posData);
+        const posData = this.materialGatherBase.posData;
+        posData.forEach(x => {
+            for (const prop of ['contract_qty', 'qc_qty']) {
+                x[prop] = undefined;
+            }
+        });
         const curStage = await this.ctx.service.stagePos.getStagesData(tender_id, stage_id);
         this.ctx.helper.assignRelaData(posData, [
             { data: curStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
@@ -313,7 +325,10 @@ class ReportMemoryMaterial {
         const materialNotJoin = this.materialGatherBase.materialNotJoin;
 
         const helper = this.ctx.helper;
+
+        console.time('calcMaterialBills');
         for (const g of gatherUtil.gclList) {
+            if (!g.contract_qty && !g.qc_qty) continue;
             g.sid = stage_id;
             g.sorder = stage_order;
             g.jiacha = 0;
@@ -339,6 +354,7 @@ class ReportMemoryMaterial {
                 g.jiacha_qty = helper.add(g.jiacha_qty, x.gather_qty);
             }
         }
+        console.timeEnd('calcMaterialBills');
         return [gatherUtil.gclList, gatherUtil.leafXmjs];
     }
 

+ 4 - 1
sql/update.sql

@@ -12,4 +12,7 @@ ADD COLUMN `show_revise_invalid`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT
 -- 很重要!!!!
 -- 请在该sql语句上方添加下一版本升级所需sql
 UPDATE `zh_sub_project` p LEFT JOIN `zh_budget` b ON p.budget_id = b.id SET p.std_id = IFNULL(b.std_id, 0);
-UPDATE `zh_sub_project` p LEFT JOIN `zh_budget_std` bs ON p.std_id = bs.id SET p.std_name = IFNULL(bs.name, '');
+UPDATE `zh_sub_project` p LEFT JOIN `zh_budget_std` bs ON p.std_id = bs.id SET p.std_name = IFNULL(bs.name, '');
+
+-- index
+ALTER TABLE `zh_material_bills_history` ADD INDEX `idx_mbid_mid_mspread` (`mb_id`, `mid`, `m_spread`);