瀏覽代碼

1 本期计量台账,台账,新增本期批注列

MaiXinRong 6 年之前
父節點
當前提交
2c6f1823b9

+ 1 - 1
app/const/spread.js

@@ -76,9 +76,9 @@ const stage = {
             {title: '变更|设计数量1',  colSpan: '2|1', rowSpan: '1|1', field: 'c_dgn_qty1', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|数量2',  colSpan: '|1', rowSpan: '|1', field: 'c_dgn_qty2', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '经济指标',  colSpan: '1', rowSpan: '2', field: 'final_dgn_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '累计完成率(%)', colSpan: '1', rowSpan: '2', field: 'percent', hAlign: 0, width: 100, readOnly: true, type: 'Number'},
-            {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@', readOnly: true},
         ],
         emptyRows: 0,
         headRows: 2,

+ 1 - 1
app/extend/helper.js

@@ -347,7 +347,7 @@ module.exports = {
      * @return {boolean}
      */
     checkZero(value) {
-        return value && Math.abs(value) > zeroRange;
+        return !(value && Math.abs(value) > zeroRange);
     },
     /**
      * 检查数字是否相等

+ 40 - 25
app/public/js/stage.js

@@ -97,7 +97,7 @@ $(document).ready(() => {
         stageId: 'id',
     };
     // 台账树结构计算相关设置
-    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'];
+    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'];
     stageTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
         'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
     stageTreeSetting.calcFun = function (node) {
@@ -434,16 +434,18 @@ $(document).ready(() => {
                 const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
                 const node = sortData[info.row];
 
-                if (node.children && node.children.length > 0) {
-                    toast('清单父项不可计量', 'error');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    return;
-                } else {
-                    const nodePos = stagePos.getLedgerPos(node.id);
-                    if (nodePos && nodePos.length > 0) {
-                        toast('该清单有部位明细,请在部位明细处计量', 'error');
+                if (col.field !== 'postil') {
+                    if (node.children && node.children.length > 0) {
+                        toast('清单父项不可计量', 'error');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
+                    } else {
+                        const nodePos = stagePos.getLedgerPos(node.id);
+                        if (nodePos && nodePos.length > 0) {
+                            toast('该清单有部位明细,请在部位明细处计量', 'error');
+                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                            return;
+                        }
                     }
                 }
                 const billsData = {
@@ -479,16 +481,21 @@ $(document).ready(() => {
                 for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
                     const node = sortData[iRow];
                     if (node) {
-                        if (node.children && node.children.length > 0) { continue; }
-                        const nodePos = stagePos.getLedgerPos(node.id);
-                        if (nodePos && nodePos.length > 0) { continue; }
-
                         const data = { lid: node.id };
+                        let filter = true;
                         for (const iCol of validCols) {
                             const colSetting = sheet.zh_setting.cols[iCol];
+                            if (colSetting.field !== 'postil') {
+                                if (node.children && node.children.length > 0) { continue; }
+                                const nodePos = stagePos.getLedgerPos(node.id);
+                                if (nodePos && nodePos.length > 0) { continue; }
+                            }
                             data[colSetting.field] = null;
+                            filter = false;
+                        }
+                        if (!filter) {
+                            datas.push(data);
                         }
-                        datas.push(data);
                     }
                 }
                 if (datas.length > 0) {
@@ -519,27 +526,35 @@ $(document).ready(() => {
                 const sheet = info.sheet;
                 const filterNodes = [], datas = [];
 
-                console.log(info.cellRange);
                 for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
                     const curRow = iRow + info.cellRange.row;
                     const node = sheet.zh_tree.getItemsByIndex(curRow);
-                    if (node.children && node.children.length > 0) {
-                        filterNodes.push(node);
-                        continue;
-                    }
-                    const nodePos = stagePos.getLedgerPos(node.id);
-                    if (nodePos && nodePos.length > 0) {
-                        filterNodes.push(node);
-                        continue;
-                    }
 
                     const data = {lid: node.id};
+                    let filter = true;
                     for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                         const curCol = info.cellRange.col + iCol;
                         const col = info.sheet.zh_setting.cols[curCol];
+
+                        if (col.field !== 'postil') {
+                            if (node.children && node.children.length > 0) {
+                                continue;
+                            }
+
+                            const nodePos = stagePos.getLedgerPos(node.id);
+                            if (nodePos && nodePos.length > 0) {
+                                continue;
+                            }
+                        }
+
                         data[col.field] = col.type === 'Number' ? _.toNumber(info.sheet.getText(curRow, curCol)) : info.sheet.getText(curRow, curCol);
+                        filter = false;
+                    }
+                    if (filter) {
+                        filterNodes.push(node);
+                    } else {
+                        datas.push(data);
                     }
-                    datas.push(data);
                 }
                 console.log(datas);
                 if (datas.length > 0) {

+ 9 - 10
app/service/project_account.js

@@ -145,16 +145,16 @@ module.exports = app => {
                     // cooperation = accountData.cooperation;
 
                     // 判断密码
-                    // if (accountData.is_admin === 1) {
-                    //     // 管理员则用sso通道判断
-                    //     const sso = new SSO(this.ctx);
-                    //     result = await sso.loginValid(data.account, data.project_password.toString());
+                    // if (accountData.password === 'SSO password') {
+                    //      // 用sso通道判断
+                    //      const sso = new SSO(this.ctx);
+                    //      result = await sso.loginValid(data.account, data.project_password.toString());
                     // } else {
-                    // 加密密码
-                    const encryptPassword = crypto.createHmac('sha1', data.account).update(data.project_password)
-                        .digest().toString('base64');
-                    result = encryptPassword === accountData.password;
-                    // }
+                        // 加密密码
+                        const encryptPassword = crypto.createHmac('sha1', data.account).update(data.project_password)
+                            .digest().toString('base64');
+                        result = encryptPassword === accountData.password;
+                    //}
                 } else {
                     // sso登录(演示版)
                     const sso = new SSO(this.ctx);
@@ -163,7 +163,6 @@ module.exports = app => {
                     accountData.id = sso.accountID;
                 }
 
-
                 // 如果成功则更新登录时间
                 if (result) {
                     const currentTime = new Date().getTime() / 1000;

+ 8 - 4
app/service/stage_bills.js

@@ -32,7 +32,14 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getLastestStageData(tid, sid, lid) {
-            const lidSql = lid ? ' And lid in (?)' : '';
+            let lidSql = '';
+            if (lid) {
+                if (lid instanceof Array) {
+                    lidSql = lid.length > 0 ? ' And lid in (' + lid.join(',') + ')' : '';
+                } else {
+                    lidSql = ' And lid in (' + this.db.escape(lid) + ')';
+                }
+            }
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                         '  INNER JOIN ( ' +
                         '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
@@ -44,10 +51,8 @@ module.exports = app => {
             if (!lid) {
                 return await this.db.query(sql, sqlParam);
             } else if (lid instanceof Array) {
-                sqlParam.push(lid.join(', '));
                 return await this.db.query(sql, sqlParam);
             } else {
-                sqlParam.push(lid);
                 return await this.db.queryOne(sql, sqlParam);
             }
         }
@@ -265,7 +270,6 @@ module.exports = app => {
             const sqlParam = [stage.times, stage.curAuditor ? stage.curAuditor.order : 0, stage.id, filter];
             const result = await this.db.queryOne(sql, sqlParam);
             return result;
-            //return this._.add(result.contract_tp, result.qc_tp);
         }
 
         async getSumTotalPriceGcl(stage, regText) {

+ 5 - 3
test/app/extend/helper.test.js

@@ -124,9 +124,11 @@ describe('test/app/extend/helper.test.js', () => {
         assert(ctx.helper.compareCode('2.4.3', '3.1.2', '.') < 0);
     });
 
-    it('test mul', function () {
+    it('test arithmetic', function () {
         const ctx = app.mockContext();
-        const a = 0.07, b = 10, m = 0.7;
-        console.log(a.mul(b) === m);
+        assert(ctx.helper.plus(0.1, 0.2) === 0.3);
+        assert(ctx.helper.minus(0.3, 0.2) === 0.1);
+        assert(ctx.helper.times(0.07, 10) === 0.7);
+        assert(ctx.helper.divide(0.32, 0.2) === 1.6);
     })
 });

+ 10 - 2
test/app/lib/analysis_excel.test.js

@@ -12,6 +12,7 @@ const { app, assert } = require('egg-mock/bootstrap');
 const AnalysisExcel = require('../../../app/lib/analysis_excel');
 const Xlsx = require('js-xlsx');
 const _ = require('lodash');
+const testTenderId = 2;
 
 describe('test/app/lib/analysis_excel.test.js', () => {
     it('analysis Test Data', function* () {
@@ -79,6 +80,7 @@ describe('test/app/lib/analysis_excel.test.js', () => {
             merge: wb.Sheets[name]["!merges"],
         };
         const ctx = app.mockContext();
+
         const analysisExcel = new AnalysisExcel();
         const templateData = yield ctx.service.tenderNodeTemplate.getData(true);
         const result = analysisExcel.analysisData(sheetData, templateData);
@@ -86,7 +88,10 @@ describe('test/app/lib/analysis_excel.test.js', () => {
         const xmj = result.codeNodes['1-2-3-1-2'];
         const gcl = xmj.children[0];
         assert(gcl.quantity === 0);
-        ctx.tender = { id: 2 };
+        // 计算需要标段的清单精度、小数位数等数据
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // pos需要记录createUserId
         ctx.session = {
             sessionUser: {
@@ -104,7 +109,10 @@ describe('test/app/lib/analysis_excel.test.js', () => {
             merge: wb.Sheets[name]["!merges"],
         };
         const ctx = app.mockContext();
-        ctx.tender = { id: 2 };
+        // 计算需要标段的清单精度、小数位数等数据
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // pos需要记录createUserId
         ctx.session = {
             sessionUser: {

+ 128 - 93
test/app/service/ledger.test.js

@@ -8,6 +8,7 @@
 'use strict';
 
 const excel = require('node-xlsx');
+const _ = require('lodash');
 
 /*const testNodeData = [
     { ledger_id: 1, ledger_pid: -1, order: 1, level: 1, full_path: '1', code: '1', is_leaf: false },
@@ -61,7 +62,8 @@ describe('test/app/service/ledger.test.js', () => {
     it('clear history test data', function* () {
         const ctx = app.mockContext();
         const result = yield ctx.service.ledger.db.delete(ctx.service.ledger.tableName, { tender_id: testTenderId });
-        assert(result.affectedRows >= 0);
+        const posResult = yield ctx.service.pos.db.delete(ctx.service.ledger.tableName, { tender_id: testTenderId });
+        assert(result.affectedRows >= 0 && posResult.affectedRows >= 0);
     });
     it('add test data(test add)', function* () {
         const ctx = app.mockContext();
@@ -378,8 +380,8 @@ describe('test/app/service/ledger.test.js', () => {
         const ctx = app.mockContext();
         // 选中1-3 降级
         const resultData = yield ctx.service.ledger.downLevelNode(testTenderId, 4);
-        // 1-3/1-3-1/1-4修改
-        assert(resultData.update.length === 3);
+        // 1-2/1-3/1-3-1/1-4修改
+        assert(resultData.update.length === 4);
 
         let node = findById(resultData.update, 4);
         assert(node.full_path === '1.3.4');
@@ -536,10 +538,14 @@ describe('test/app/service/ledger.test.js', () => {
      */
     it('test updateCalc - update 1', function* () {
         const ctx = app.mockContext();
+        // 计算需使用清单精度、小数位数
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // 修改202-2-e(1-1-1下)(id=12)的quantity为2.00000001, unit_price位3.0000005
-        const qty = 2.00000001;
-        const up = 3.0000005;
-        const tp = 6.00000103;
+        const qty = 2.00000001, fQty = ctx.helper.round(qty, ctx.tender.info.precision.other.value);
+        const up = 3.0000005, fUp = ctx.helper.round(up, ctx.tender.info.decimal.up);
+        const tp = 6.00000103, fTp = ctx.helper.times(fQty, fUp);
         const node1 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 12);
         assert(node1);
         const resultData = yield ctx.service.ledger.updateCalc(testTenderId, {
@@ -551,7 +557,9 @@ describe('test/app/service/ledger.test.js', () => {
         });
         assert(resultData.update.length === 1);
         let node = findById(resultData.update, 12);
-        assert(node.total_price.toFixed(8) == tp);
+        assert(node.quantity === fQty);
+        assert(node.unit_price === fUp);
+        assert(node.total_price == fTp);
     });
     /* 期望运行结果:
         1
@@ -559,7 +567,7 @@ describe('test/app/service/ledger.test.js', () => {
         │   ├── 1-1-1
         │   │   └── 202-2
         │   │       ├── 202-2-c
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       └── 202-2-e         2           3           6
         │   └── 1-1-4
         ├── 1-1-2
         │   └── 1-1-3
@@ -576,13 +584,28 @@ describe('test/app/service/ledger.test.js', () => {
      */
     it('test updateCalc - update N', function* () {
         const ctx = app.mockContext();
+        // 计算需使用清单精度、小数位数
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // 修改202-2-c(1-1-1下)(id=11)的quantity为4.00000025, unit_price为6.0000083
         //    202-2-c(1-2-2下)(id=20)的quantity为2.0000001, unit_price为5.000065
         //    202-2-e(1-2-2下)(id=21)的quantity为8.0000579, unit_price为4.0000086
         const qty = [4.00000025, 2.0000001, 8.0000579];
         const up = [6.0000083, 5.000065, 4.0000086];
         const tp = [24.0000347, 10.0001305, 32.0003004];
-        const sum = [30.00003573, 42.0004309, 72.00046663]
+        // 实际结果
+        const fQty = [], fUp = [], fTp = [];
+        for (const q of qty) {
+            fQty.push(ctx.helper.round(q, ctx.tender.info.precision.other.value));
+        }
+        for (const p of up) {
+            fUp.push(ctx.helper.round(p, ctx.tender.info.decimal.up));
+        }
+        for (const i in qty) {
+            fTp.push(ctx.helper.times(fQty[i], fUp[i]));
+        }
+
         const node1 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 11);
         assert(node1);
         const node2 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 20);
@@ -613,19 +636,25 @@ describe('test/app/service/ledger.test.js', () => {
         assert(resultData.update.length === 3);
 
         let node = findById(resultData.update, 11);
-        assert(node.total_price.toFixed(8) == tp[0]);
+        assert(node.quantity == fQty[0]);
+        assert(node.unit_price == fUp[0]);
+        assert(node.total_price === fTp[0]);
         node = findById(resultData.update, 20);
-        assert(node.total_price.toFixed(8) == tp[1]);
+        assert(node.quantity == fQty[1]);
+        assert(node.unit_price == fUp[1]);
+        assert(node.total_price === fTp[1]);
         node = findById(resultData.update, 21);
-        assert(node.total_price.toFixed(8) == tp[2]);
+        assert(node.quantity == fQty[2]);
+        assert(node.unit_price == fUp[2]);
+        assert(node.total_price == fTp[2]);
     });
     /* 期望运行结果:
         1
         ├── 1-1
         │   ├── 1-1-1
         │   │   └── 202-2
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   └── 1-1-4
         ├── 1-1-2
         │   └── 1-1-3
@@ -633,8 +662,8 @@ describe('test/app/service/ledger.test.js', () => {
         │   ├── 1-2-1
         │   ├── 1-2-2
         │   │   └── 202-2
-        │   │       ├── 202-2-c     2.0000001   5.000065    10.0001305
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   │       ├── 202-2-c     2           5           10
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -654,20 +683,20 @@ describe('test/app/service/ledger.test.js', () => {
         ├── 1-1
         │   ├── 1-1-1
         │   │   └── 202-2
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   ├── 1-1-4
         │   └── 202-2
-        │       ├── 202-2-c         4.00000025  6.0000083   24.0000347
-        │       └── 202-2-e         2.00000001  3.0000005   6.00000103
+        │       ├── 202-2-c         4           6           24
+        │       └── 202-2-e         2           3           6
         ├── 1-1-2
         │   └── 1-1-3
         ├── 1-2
         │   ├── 1-2-1
         │   ├── 1-2-2
         │   │   └── 202-2
-        │   │       ├── 202-2-c     2.0000001   5.000065    10.0001305
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   │       ├── 202-2-c     2           5           10
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -685,20 +714,20 @@ describe('test/app/service/ledger.test.js', () => {
         ├── 1-1
         │   ├── 1-1-1
         │   │   └── 202-2
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   └── 1-1-4
         │       └── 202-2
-        │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │           └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │           ├── 202-2-c     4           6           24
+        │           └── 202-2-e     2           3           6
         ├── 1-1-2
         │   └── 1-1-3
         ├── 1-2
         │   ├── 1-2-1
         │   ├── 1-2-2
         │   │   └── 202-2
-        │   │       ├── 202-2-c     2.0000001   5.000065    10.0001305
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   │       ├── 202-2-c     2           5           10
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -712,23 +741,23 @@ describe('test/app/service/ledger.test.js', () => {
             ├── 1-1
             │   ├── 1-1-1
             │   │   └── 202-2
-            │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-            │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+            │   │       ├── 202-2-c     4           6           24
+            │   │       └── 202-2-e     2           3           6
             │   └── 1-1-4
             │       ├── 202-2
-            │       │   ├── 202-2-c     4.00000025  6.0000083   24.0000347
-            │       │   └── 202-2-e     2.00000001  3.0000005   6.00000103
+            │       │   ├── 202-2-c     4           6           24
+            │       │   └── 202-2-e     2           3           6
             │       └── 202-2
-            │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
-            │           └── 202-2-e     2.00000001  3.0000005   6.00000103
+            │           ├── 202-2-c     4           6           24
+            │           └── 202-2-e     2           3           6
             ├── 1-1-2
             │   └── 1-1-3
             ├── 1-2
             │   ├── 1-2-1
             │   ├── 1-2-2
             │   │   └── 202-2
-            │   │       ├── 202-2-c     2.0000001   5.000065    10.0001305
-            │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+            │   │       ├── 202-2-c     2           5           10
+            │   │       └── 202-2-e     8           4           32
             │   ├── 1-2-3
             │   └── 1-3
             │       └── 1-3-1
@@ -743,23 +772,23 @@ describe('test/app/service/ledger.test.js', () => {
         ├── 1-1
         │   ├── 1-1-1
         │   │   └── 202-2
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   ├── 1-1-4
         │   └── 202-2
-        │       ├── 202-2-c         4.00000025  6.0000083   24.0000347
-        │       ├── 202-2-e         2.00000001  3.0000005   6.00000103
+        │       ├── 202-2-c         4           6           24
+        │       ├── 202-2-e         2           3           6
         │       └── 202-2
-        │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │           └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │           ├── 202-2-c     4           6           24
+        │           └── 202-2-e     2           3           6
         ├── 1-1-2
         │   └── 1-1-3
         ├── 1-2
         │   ├── 1-2-1
         │   ├── 1-2-2
         │   │   └── 202-2
-        │   │       ├── 202-2-c     2.0000001   5.000065    10.0001305
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   │       ├── 202-2-c     2           5           10
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -778,22 +807,22 @@ describe('test/app/service/ledger.test.js', () => {
         ├── 1-1
         │   ├── 1-1-1
         │   │   └── 202-2
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   ├── 1-1-4
         │   └── 202-2
-        │       ├── 202-2-c         4.00000025  6.0000083   24.0000347
-        │       ├── 202-2-e         2.00000001  3.0000005   6.00000103
+        │       ├── 202-2-c         4           6           24
+        │       ├── 202-2-e         2           3           6
         │       └── 202-2
-        │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │           └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │           ├── 202-2-c     4           6           24
+        │           └── 202-2-e     2           3           6
         ├── 1-1-2
         │   └── 1-1-3
         ├── 1-2
         │   ├── 1-2-1
         │   ├── 1-2-2
         │   │   └── 202-2
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -821,27 +850,27 @@ describe('test/app/service/ledger.test.js', () => {
         // 从标准库中添加101-1
     });
     /* 期望运行结果:
-        1                                                   122.00040759
-        ├── 1-1                                             90.00009719
-        │   ├── 1-1-1                                       30.00003573
-        │   │   └── 202-2                                   30.00003573
-        │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
+        1
+        ├── 1-1
+        │   ├── 1-1-1
+        │   │   └── 202-2
+        │   │       ├── 202-2-c     4           6           24
+        │   │       └── 202-2-e     2           3           6
         │   ├── 1-1-4
         │   ├── 1-1-5
-        │   └── 202-2                                       60.00007146
-        │       ├── 202-2-c         4.00000025  6.0000083   24.0000347
-        │       ├── 202-2-e         2.00000001  3.0000005   6.00000103
-        │       └── 202-2                                   30.00003573
-        │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
-        │           └── 202-2-e     2.00000001  3.0000005   6.00000103
+        │   └── 202-2
+        │       ├── 202-2-c         4           6           24
+        │       ├── 202-2-e         2           3           6
+        │       └── 202-2
+        │           ├── 202-2-c     4           6           24
+        │           └── 202-2-e     2           3           6
         ├── 1-1-2
         │   └── 1-1-3
-        ├── 1-2                                             32.0003004
+        ├── 1-2
         │   ├── 1-2-1
-        │   ├── 1-2-2                                       32.0003004
-        │   │   └── 202-2                                   32.0003004
-        │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
+        │   ├── 1-2-2
+        │   │   └── 202-2
+        │   │       └── 202-2-e     8           4           32
         │   ├── 1-2-3
         │   └── 1-3
         │       └── 1-3-1
@@ -875,7 +904,6 @@ describe('test/app/service/ledger.test.js', () => {
         assert(result2.update.length === 1);
         assert(result2.update[0].code = '1-4-2-1');
         assert(!result2.update[0].is_leaf);
-        assert(result2.expand.length === 4);
         // 从标准库添加1-4-2-1-1
         const condition3 = { list_id: 1, code: '1-4-2-1-1'};
         const libData3 = yield ctx.service.stdChapter.getDataByCondition(condition3);
@@ -890,29 +918,28 @@ describe('test/app/service/ledger.test.js', () => {
         assert(result3.update.length === 1);
         assert(result3.update[0].code === '1-4-2-1-2');
         assert(result3.update[0].order === 2);
-        assert(result3.expand.length === 5);
     });
     /* 期望运行结果:
-        1                                                   122.00040759
-        ├── 1-1                                             90.00009719
-        │   ├── 1-1-1                                       30.00003573
-        │   │   └── 202-2                                   30.00003573
+        1
+        ├── 1-1
+        │   ├── 1-1-1
+        │   │   └── 202-2
         │   │       ├── 202-2-c     4.00000025  6.0000083   24.0000347
         │   │       └── 202-2-e     2.00000001  3.0000005   6.00000103
         │   ├── 1-1-4
         │   ├── 1-1-5
-        │   └── 202-2                                       60.00007146
+        │   └── 202-2
         │       ├── 202-2-c         4.00000025  6.0000083   24.0000347
         │       ├── 202-2-e         2.00000001  3.0000005   6.00000103
-        │       └── 202-2                                   30.00003573
+        │       └── 202-2
         │           ├── 202-2-c     4.00000025  6.0000083   24.0000347
         │           └── 202-2-e     2.00000001  3.0000005   6.00000103
         ├── 1-1-2
         │   └── 1-1-3
-        ├── 1-2                                             32.0003004
+        ├── 1-2
         │   ├── 1-2-1
-        │   ├── 1-2-2                                       32.0003004
-        │   │   └── 202-2                                   32.0003004
+        │   ├── 1-2-2
+        │   │   └── 202-2
         │   │       └── 202-2-e     8.0000579   4.0000086   32.0003004
         │   ├── 1-2-3
         │   └── 1-3
@@ -926,6 +953,10 @@ describe('test/app/service/ledger.test.js', () => {
     // 批量插入
     it('test batchInsertChild', function* () {
         const ctx = app.mockContext();
+        // 计算需使用清单精度、小数位数
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // pos需要记录createUserId
         ctx.session = {
             sessionUser: {
@@ -946,12 +977,12 @@ describe('test/app/service/ledger.test.js', () => {
         // 选中1-1-3(id=14)
         const result = yield ctx.service.ledger.batchInsertChild(testTenderId, 14, batchData);
         assert(result.ledger.create.length === 2);
-        let node = findById(result.ledger.create, 36);
-        assert(node.quantity.toFixed(8) == 3);
-        assert(node.total_price.toFixed(8) == 6);
-        node = findById(result.ledger.create, 37);
-        assert(node.quantity.toFixed(8) == 7);
-        assert(node.total_price.toFixed(8) == 21);
+        let node = _.find(result.ledger.create, {name: 'A1'});
+        assert(node.quantity === 3);
+        assert(node.total_price === 6);
+        node = _.find(result.ledger.create, {name: 'A2'});
+        assert(node.quantity === 7);
+        assert(node.total_price === 21);
 
         assert(result.pos.length === 4);
     });
@@ -995,6 +1026,10 @@ describe('test/app/service/ledger.test.js', () => {
     // 批量插入
     it('test batchInsertNext', function* () {
         const ctx = app.mockContext();
+        // 计算需使用清单精度、小数位数
+        ctx.tender = {id: testTenderId};
+        ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
+        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
         // pos需要记录createUserId
         ctx.session = {
             sessionUser: {
@@ -1004,11 +1039,11 @@ describe('test/app/service/ledger.test.js', () => {
 
         const batchData = [
             {
-                b_code: 403-1, name: 'A1', unit: 'B1', price: 2,
+                b_code: 403-1, name: 'A3', unit: 'B1', price: 2,
                 pos: [{name: 'Y1', quantity: 5}, {name: 'Y2', quantity: 6}],
             },
             {
-                b_code: 404-1, name: 'A2', unit: 'B2', price: 3,
+                b_code: 404-1, name: 'A4', unit: 'B2', price: 3,
                 pos: [{name: 'Y1', quantity: 7}, {name: 'Y2', quantity: 8}],
             },
         ];
@@ -1016,12 +1051,12 @@ describe('test/app/service/ledger.test.js', () => {
         const result = yield ctx.service.ledger.batchInsertNext(testTenderId, 14, batchData);
 
         assert(result.ledger.create.length === 2);
-        let node = findById(result.ledger.create, 39);
-        assert(node.quantity.toFixed(8) == 11);
-        assert(node.total_price.toFixed(8) == 22);
-        node = findById(result.ledger.create, 40);
-        assert(node.quantity.toFixed(8) == 15);
-        assert(node.total_price.toFixed(8) == 45);
+        let node = _.find(result.ledger.create, {name: 'A3'});
+        assert(node.quantity === 11);
+        assert(node.total_price === 22);
+        node = _.find(result.ledger.create, {name: 'A4'});
+        assert(node.quantity === 15);
+        assert(node.total_price === 45);
 
         assert(result.pos.length === 4);
     });
@@ -1075,7 +1110,7 @@ describe('test/app/service/ledger.test.js', () => {
 
         // 统计202-2(id=23)前两个子节点的金额
         const result1 = yield ctx.service.ledger.addUpChildren(testTenderId, 23, 2, '<=');
-        assert(result1 && result1.toFixed(8) == 30.00003573);
+        assert(result1 && result1 === 30);
         // 数据库不再存储父项金额,以下两个查询不能获得实际金额
         // 统计202-2(id=23)后两个子节点的金额
         //const result2 = yield ctx.service.ledger.addUpChildren(testTenderId, 23, 2, '>=');

+ 8 - 3
test/app/service/stage_bills.test.js

@@ -16,16 +16,21 @@ describe('test/app/service/stage_bills.test.js', () => {
         const stage = yield ctx.service.stage.getDataByCondition({
             id: 4
         });
+        stage.curTimes = stage.times;
+        stage.curOrder = 0;
         const result = yield ctx.service.stageBills.getSumTotalPrice(stage);
-        const bills  = yield ctx.service.stageBills.getStage
-        assert(result === 209151.2);
+        assert(result.contract_tp === 209151.2);
+        assert(result.qc_tp === null);
     });
     it('test getSumTotalPriceGcl', function* () {
         const ctx = app.mockContext();
         const stage = yield ctx.service.stage.getDataByCondition({
             id: 4
         });
+        stage.curTimes = stage.times;
+        stage.curOrder = 0;
         const result = yield ctx.service.stageBills.getSumTotalPriceGcl(stage, '1[0-9]3-');
-        assert(result === 169151.2);
+        assert(result.contract_tp === 169151.2);
+        assert(result.qc_tp === null);
     });
 });

+ 1 - 1
test/app/service/tender.test.js

@@ -16,7 +16,7 @@ describe('test/app/service/tender.test.js', () => {
         const ctx = app.mockContext();
         const tenderInfo = yield ctx.service.tender.getDataById(14);
         assert(tenderInfo.id === 14);
-        // assert(tenderInfo.name === '测试标段5');
+        assert(tenderInfo.name === '测试标段5');
     });
 
     it('save test',function* () {

二進制
test/app/test_file/deal-upload-test.xls