Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 2 лет назад
Родитель
Сommit
0e7cbb78d4
4 измененных файлов с 29 добавлено и 8 удалено
  1. 4 4
      app/controller/payment_controller.js
  2. 18 2
      app/lib/rm/material.js
  3. 3 1
      app/lib/rpt_data_analysis.js
  4. 4 1
      sql/update.sql

+ 4 - 4
app/controller/payment_controller.js

@@ -80,8 +80,8 @@ module.exports = app => {
                     t.have_detail = await ctx.service.paymentDetail.haveDetail2Tender(t.id);
                 }
             }
-            responseData.data.folderList = folderList;
-            responseData.data.tenderList = tenderList;
+            responseData.data.folderList = ctx.helper._.orderBy(folderList, ['in_time'], ['asc']);
+            responseData.data.tenderList = ctx.helper._.orderBy(tenderList, ['in_time'], ['asc']);
             ctx.body = responseData;
         }
 
@@ -224,8 +224,8 @@ module.exports = app => {
                 const tenderList = await ctx.service.paymentTender.getList(ctx.session.sessionUser.accountId, auditPermission);
                 // 获取你创建的目录及对应目录下的所有目录
                 const folderList = await ctx.service.paymentFolder.getList(ctx.session.sessionUser.accountId, tenderList, auditPermission);
-                responseData.data.folderList = folderList;
-                responseData.data.tenderList = tenderList;
+                responseData.data.folderList = ctx.helper._.orderBy(folderList, ['in_time'], ['asc']);
+                responseData.data.tenderList = ctx.helper._.orderBy(tenderList, ['in_time'], ['asc']);
                 ctx.body = responseData;
             } catch (err) {
                 this.log(err);

+ 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];
     }
 

+ 3 - 1
app/lib/rpt_data_analysis.js

@@ -1917,7 +1917,8 @@ const masterCross = {
             quoteFields: ['quantity'],
             gatherFields: [],
         },
-        target: 'master_converse'
+        target: 'master_converse',
+        base: 'main',
     },
     _converse: function(ctx, options, mainTable, subTable) {
         const data = [];
@@ -1939,6 +1940,7 @@ const masterCross = {
                 temp[options.main.prefix + f] = m[f];
             }
             const rela = subTable.filter(x => { return x[options.sub.subKey] === m[options.sub.masterKey]; });
+            if (options.base === 'sub' && rela.length === 0) continue;
             for (const cd of converseData) {
                 const nd = JSON.parse(JSON.stringify(temp));
                 nd.quote = false;

+ 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`);