Browse Source

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

Tony Kang 3 năm trước cách đây
mục cha
commit
856272dadb
49 tập tin đã thay đổi với 1412 bổ sung349 xóa
  1. 8 1
      app/base/base_bills_service.js
  2. 21 8
      app/base/base_tree_service.js
  3. 20 7
      app/const/spread.js
  4. 15 0
      app/const/stage_filter.js
  5. 4 1
      app/const/tender_info.js
  6. 2 1
      app/controller/budget_controller.js
  7. 70 46
      app/controller/stage_controller.js
  8. 9 5
      app/lib/analysis_excel.js
  9. 1 1
      app/lib/rptCustomData.js
  10. 10 8
      app/lib/sum_load.js
  11. 2 1
      app/public/css/main.css
  12. 4 0
      app/public/js/budget_compare.js
  13. 3 1
      app/public/js/gcl_gather.js
  14. 17 6
      app/public/js/ledger.js
  15. 17 0
      app/public/js/path_tree.js
  16. 13 1
      app/public/js/shares/sjs_setting.js
  17. 13 9
      app/public/js/spreadjs_rela/spreadjs_zh.js
  18. 6 0
      app/public/js/sr_detail.js
  19. 48 30
      app/public/js/stage.js
  20. 1 1
      app/public/js/stage_gather.js
  21. 33 25
      app/public/js/stage_im.js
  22. 20 6
      app/service/change.js
  23. 6 6
      app/service/change_audit_list.js
  24. 10 0
      app/service/change_ledger.js
  25. 1 12
      app/service/ledger.js
  26. 37 0
      app/service/ledger_extra.js
  27. 5 0
      app/service/ledger_history.js
  28. 6 6
      app/service/ledger_revise.js
  29. 2 16
      app/service/pos.js
  30. 37 0
      app/service/pos_extra.js
  31. 4 2
      app/service/project.js
  32. 4 26
      app/service/report_memory.js
  33. 5 6
      app/service/revise_audit.js
  34. 1 0
      app/service/stage.js
  35. 2 14
      app/service/stage_audit.js
  36. 15 7
      app/service/stage_bills.js
  37. 6 15
      app/service/stage_bills_final.js
  38. 44 39
      app/service/stage_change.js
  39. 2 13
      app/service/stage_change_final.js
  40. 8 7
      app/service/stage_pos.js
  41. 4 14
      app/service/stage_pos_final.js
  42. 12 8
      app/service/stage_stash.js
  43. 14 0
      app/view/setting/fun.ejs
  44. 1 0
      app/view/stage/gather.ejs
  45. 11 0
      app/view/stage/index.ejs
  46. 10 0
      app/view/tender/detail_modal.ejs
  47. 70 0
      db_script/minus_no_value.js
  48. 27 0
      publish.md
  49. 731 0
      sql/update.sql

+ 8 - 1
app/base/base_bills_service.js

@@ -559,7 +559,7 @@ class BaseBillsSerivce extends TreeService {
         }
     }
 
-    async pasteBlockData (tid, sid, pasteData, defaultData) {
+    async pasteBlockData(tid, sid, pasteData, defaultData) {
         if ((tid <= 0) || (sid <= 0)) return [];
 
         if (!pasteData || pasteData.length <= 0) throw '复制数据错误';
@@ -703,6 +703,13 @@ class BaseBillsSerivce extends TreeService {
             pos: pastePosData,
         };
     }
+
+    async getCompleteDataById(id) {
+        const ledgerBills = await this.getDataById(id);
+        const ledgerExtra = await this.ctx.service.ledgerExtra.getDataById(id);
+        ledgerBills.is_tp = ledgerExtra ? ledgerExtra.is_tp : 0;
+        return ledgerBills
+    }
 }
 
 module.exports = BaseBillsSerivce;

+ 21 - 8
app/base/base_tree_service.js

@@ -351,6 +351,16 @@ class TreeService extends Service {
     _cacheMaxLid(mid, maxId) {
         this.cache.set(this.setting.keyPre + mid , maxId, 'EX', this.ctx.app.config.cacheTime);
     }
+    /**
+     * 移除最大节点id
+     *
+     * @param {Number} mid - master id
+     * @return {Number}
+     * @private
+     */
+    async _removeCacheMaxLid(mid) {
+        return await this.cache.del(this.setting.keyPre + mid);
+    }
 
     /**
      * 更新order
@@ -737,7 +747,7 @@ class TreeService extends Service {
             selfOperate: '-',
         });
         this.sqlBuilder.setUpdateData(this.setting.fullPath, {
-            value: [this.setting.fullPath, this.db.escape(select[this.setting.pid] + '-'), this.db.escape('')],
+            value: [this.setting.fullPath, this.db.escape(`-${select[this.setting.pid]}-`), this.db.escape('-')],
             literal: 'Replace',
         });
         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
@@ -842,7 +852,7 @@ class TreeService extends Service {
                 updateData[this.setting.pid] = parent[this.setting.pid];
                 updateData[this.setting.order] = parent[this.setting.order] + i + 1;
                 updateData[this.setting.level] = s[this.setting.level] - 1;
-                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(s[this.setting.pid] + '-', '');
+                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(`-${s[this.setting.pid]}-`, '-');
                 newPath.push(updateData[this.setting.fullPath]);
                 if (s.is_leaf && s.id === last.id) {
                     const nexts = await this.getNextsData(mid, parent[this.setting.kid], last[this.setting.order]);
@@ -881,7 +891,7 @@ class TreeService extends Service {
      * @return {Promise<*>}
      * @private
      */
-    async _syncDownlevelChildren(select, pre) {
+    async _syncDownlevelChildren(select, newFullPath) {
         this.initSqlBuilder();
         this.sqlBuilder.setAndWhere(this.setting.mid, {
             value: select[this.setting.mid],
@@ -896,7 +906,7 @@ class TreeService extends Service {
             selfOperate: '+',
         });
         this.sqlBuilder.setUpdateData(this.setting.fullPath, {
-            value: [this.setting.fullPath, this.db.escape(select[this.setting.kid] + '-'), this.db.escape(pre[this.setting.kid] + '-' + select[this.setting.kid] + '-')],
+            value: [this.setting.fullPath, this.db.escape(select[this.setting.fullPath] + '-'), this.db.escape(newFullPath + '-')],
             literal: 'Replace',
         });
         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
@@ -933,13 +943,16 @@ class TreeService extends Service {
                 updateData[this.setting.pid] = pre[this.setting.kid];
                 updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + i + 1 : i + 1;
                 updateData[this.setting.level] = s[this.setting.level] + 1;
-                const orgLastPath = s[this.setting.level] === 1 ? s[this.setting.kid] : '-' + s[this.setting.kid];
-                const newLastPath = s[this.setting.level] === 1 ? pre[this.setting.kid] + '-' + s[this.setting.kid] : '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
-                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(orgLastPath, newLastPath);
+                if (s[this.setting.level] === 1) {
+                    updateData[this.setting.fullPath] = pre[this.setting.kid] + '-' + s[this.setting.kid];
+                } else {
+                    const index = s[this.setting.fullPath].lastIndexOf(s[this.setting.kid]);
+                    updateData[this.setting.fullPath] = s[this.setting.fullPath].substring(0, index) + '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
+                }
                 newPath.push(updateData[this.setting.fullPath]);
                 await this.transaction.update(this.tableName, updateData);
                 // 选中节点--全部子节点(含孙) level++, full_path
-                await this._syncDownlevelChildren(s, pre);
+                await this._syncDownlevelChildren(s, updateData[this.setting.fullPath]);
             }
             // 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段
             const updateData2 = { id: pre.id };

+ 20 - 7
app/const/spread.js

@@ -17,6 +17,7 @@ const thirdPartyCols = {
     gxby: ['gxby'],
     dagl: ['dagl']
 };
+const minusNoValueCols = ['qc_minus_qty'];
 
 const withCl = {
     ledger: {
@@ -195,8 +196,9 @@ const stageTz = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -227,6 +229,8 @@ const stageTz = {
         defaultRowHeight: 21,
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
+        frozenColCount: 5,
+        frozenLineColor: '#93b5e4',
     },
     pos: {
         cols: [
@@ -236,8 +240,9 @@ const stageTz = {
             {title: '台账数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 60, formatter: '@', readOnly: true},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -273,8 +278,9 @@ const stageCl = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -304,6 +310,8 @@ const stageCl = {
         defaultRowHeight: 21,
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
+        frozenColCount: 5,
+        frozenLineColor: '#93b5e4',
     },
     pos: {
         cols: [
@@ -312,8 +320,9 @@ const stageCl = {
             {title: '位置', colSpan: '1', rowSpan: '2', field: 'position', hAlign: 0, width: 60, formatter: '@'},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -350,8 +359,9 @@ const stageNoCl = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -381,6 +391,8 @@ const stageNoCl = {
         defaultRowHeight: 21,
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
+        frozenColCount: 5,
+        frozenLineColor: '#93b5e4',
     },
     pos: {
         cols: [
@@ -389,8 +401,9 @@ const stageNoCl = {
             {title: 'ex_memo1', colSpan: '1', rowSpan: '2', field: 'ex_memo1', hAlign: 0, width: 100, formatter: '@', cellType: 'ellipsisAutoTip'},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -587,7 +600,7 @@ module.exports = {
     stageNoCl,
     stageGather,
     stageCompare,
-    filterCols: { tzWithoutCols, dgnCols, clCols, stageDgnCols, realCompleteCols, thirdPartyCols},
+    filterCols: { tzWithoutCols, dgnCols, clCols, stageDgnCols, realCompleteCols, thirdPartyCols, minusNoValueCols},
     measure,
     blank,
 };

+ 15 - 0
app/const/stage_filter.js

@@ -0,0 +1,15 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+module.exports = {
+    stageBills: { index: ['lid'], times: 'times', order: 'order' },
+    stagePos: { index: ['pid'], times: 'times', order: 'order' },
+    stageChange: { index: ['lid', 'pid', 'cbid', 'no_value'], times: 'stimes', order: 'sorder', },
+};

+ 4 - 1
app/const/tender_info.js

@@ -166,13 +166,16 @@ const defaultInfo = {
     },
     fun_rela: {
         hintOver: true,
+        stage_change: {
+            minusNoValue: false,
+        },
         sum_load: {
             ignoreParent: false,
         },
         stage_rela: {
             show: false,
         },
-    }
+    },
 };
 
 module.exports = {

+ 2 - 1
app/controller/budget_controller.js

@@ -205,7 +205,7 @@ module.exports = app => {
                     {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 180, formatter: '@', cellType: 'tree'},
                     {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 120, formatter: '@'},
                     {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'},
-                    {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
+                    {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit', comboEdit: true},
                     {title: '设计数量|数量1', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 80, type: 'Number'},
                     {title: '|数量2', colSpan: '|1', rowSpan: '|1', field: 'dgn_qty2', hAlign: 2, width: 80, type: 'Number'},
                     {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -221,6 +221,7 @@ module.exports = app => {
                 defaultRowHeight: 21,
                 headerFont: '12px 微软雅黑',
                 font: '12px 微软雅黑',
+                localCache: { key: 'budget', colWidth: true },
             };
             if (!needGcl) {
                 spreadSetting.cols = spreadSetting.cols.filter(x => {

+ 70 - 46
app/controller/stage_controller.js

@@ -88,13 +88,21 @@ module.exports = app => {
          * 获取SpreadSetting
          * @private
          */
-        _getSpreadSetting() {
+        _getSpreadSetting(funInfo) {
             const _ = this.app._;
             function removeFieldCols(setting, cols) {
                 _.remove(setting.cols, function(c) {
                     return cols.indexOf(c.field) > -1;
                 });
             }
+            function hiddenFieldCols(setting, cols) {
+                setting.cols.forEach(x => {
+                    if (cols.indexOf(x.field) >= 0) {
+                        x.defaultVisible = false;
+                        x.visible = false;
+                    }
+                });
+            }
             const tender = this.ctx.tender,
                 stage = this.ctx.stage;
             const stageSetting = tender.data.measure_type === measureType.tz.value
@@ -116,6 +124,10 @@ module.exports = app => {
                 removeFieldCols(ledger, spreadConst.filterCols.thirdPartyCols.dagl);
                 removeFieldCols(pos, spreadConst.filterCols.thirdPartyCols.dagl);
             }
+            if (!funInfo.minusNoValue || !tender.info.fun_rela.stage_change.minusNoValue) {
+                hiddenFieldCols(ledger, spreadConst.filterCols.minusNoValueCols);
+                hiddenFieldCols(pos, spreadConst.filterCols.minusNoValueCols);
+            }
             if (this.ctx.stage.readOnly || this.ctx.stage.revising) {
                 ledger.readOnly = true;
                 pos.readOnly = true;
@@ -168,7 +180,8 @@ module.exports = app => {
             try {
                 await this._getStageAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
-                [renderData.ledgerSpread, renderData.posSpread] = this._getSpreadSetting();
+                const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
+                [renderData.ledgerSpread, renderData.posSpread] = this._getSpreadSetting(projectFunInfo);
                 const sjsRela = await this.ctx.service.project.getSjsRela(ctx.session.sessionProject.id);
                 this.ctx.helper.refreshSpreadShow(sjsRela.ledgerCol, [renderData.ledgerSpread, renderData.posSpread]);
                 renderData.changeConst = changeConst;
@@ -193,7 +206,7 @@ module.exports = app => {
                 renderData.sfData = sfData;
                 // 收方单附件删除权限
                 renderData.sfAttDelPower = ctx.session.sessionUser.accountId === ctx.stage.user_id || ctx.helper._.findIndex(ctx.stage.auditors2, { aid: ctx.session.sessionUser.accountId }) !== -1;
-                const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
+                renderData.minusNoValue = projectFunInfo.minusNoValue && ctx.tender.info.fun_rela.stage_change.minusNoValue;
                 renderData.hintOver = projectFunInfo.hintOver && ctx.tender.info.fun_rela.hintOver;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
@@ -223,34 +236,40 @@ module.exports = app => {
 
         _getLedgerColumn(sjsRela) {
             const tender = this.ctx.tender;
-            const ledgerColumn = [
+            this.ledgerColumn = [
                 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
                 'code', 'b_code', 'name', 'unit', 'unit_price',
-                'quantity', 'total_price', 'memo', 'drawing_code', 'is_tp', 'node_type'];
-            if (this.ctx.session.sessionProject.gxby) ledgerColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
-            if (this.ctx.session.sessionProject.dagl) ledgerColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
-            if (tender.data.measure_type === measureType.gcl.value) ledgerColumn.push('deal_qty', 'deal_tp');
-            if (tender.info.display.ledger.dgnQty) ledgerColumn.push('dgn_qty1', 'dgn_qty2');
-
-            const posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'quantity', 'add_stage_order', 'drawing_code'];
-            if (tender.info.display.stage.realComplete) posColumn.push('real_qty');
-            if (this.ctx.session.sessionProject.gxby) posColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
-            if (this.ctx.session.sessionProject.dagl) posColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
+                'quantity', 'total_price', 'memo', 'drawing_code', 'node_type'];
+            if (tender.data.measure_type === measureType.gcl.value) this.ledgerColumn.push('deal_qty', 'deal_tp');
+            if (tender.info.display.ledger.dgnQty) this.ledgerColumn.push('dgn_qty1', 'dgn_qty2');
+
+            this.ledgerExtraColumn = ['is_tp'];
+            if (this.ctx.session.sessionProject.gxby) this.ledgerExtraColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
+            if (this.ctx.session.sessionProject.dagl) this.ledgerExtraColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
+
+
+            this.posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'quantity', 'add_stage_order', 'drawing_code'];
+            if (tender.info.display.stage.realComplete) this.posColumn.push('real_qty');
+
+            this.posExtraColumn = [];
+            if (this.ctx.session.sessionProject.gxby) this.posExtraColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
+            if (this.ctx.session.sessionProject.dagl) this.posExtraColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
+
+            if (!sjsRela) return;
             for (const field of sjsRela.ledgerCol) {
                 if (field.show) {
-                    ledgerColumn.push(field.field);
-                    posColumn.push(field.field);
+                    this.ledgerColumn.push(field.field);
+                    this.posColumn.push(field.field);
                 }
             }
-            return [ledgerColumn, posColumn];
         }
 
-        async _getStageLedgerData(ctx, ledgerColumn) {
-            // const ledgerData = ctx.stage.ledgerHis
-            //     ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
-            //     : await ctx.service.ledger.getAllDataByCondition({ columns: ledgerColumn, where: { tender_id: ctx.tender.id } });
-            const ledgerData = await ctx.service.ledger.getAllDataByCondition({ columns: ledgerColumn, where: { tender_id: ctx.tender.id } });
+        async _getStageLedgerData(ctx) {
+            const ledgerData = ctx.stage.ledgerHis
+                ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
+                : await ctx.service.ledger.getAllDataByCondition({ columns: this.ledgerColumn, where: { tender_id: ctx.tender.id } });
             const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
+            const extraData = await ctx.service.ledgerExtra.getData(ctx.tender.id, this.ledgerExtraColumn);
             const importData = await ctx.service.stageImportChange.getImportLid(ctx.stage.id);
             let curStageData;
             // 当前操作人查看最新数据,其他人查看历史数据
@@ -266,19 +285,20 @@ module.exports = app => {
             // 查询截止上期数据
             const preStageData = ctx.stage.order > 1 ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(ledgerData, [
-                { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id'},
-                { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid'},
-                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid' },
-                { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', relaId: 'lid' },
+                { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id' },
+                { data: extraData, fields: this.ledgerExtraColumn, prefix: '', relaId: 'id' },
+                { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid' },
+                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'lid' },
+                { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'used'], prefix: 'pre_', relaId: 'lid' },
             ]);
             return ledgerData;
         }
-        async _getStagePosData(ctx, posColumn) {
+        async _getStagePosData(ctx) {
             let curStageData;
-            // const posData =  ctx.stage.ledgerHis
-            //     ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
-            //     : await ctx.service.pos.getAllDataByCondition({ columns: posColumn, where: { tid: ctx.tender.id } });
-            const posData = await ctx.service.pos.getAllDataByCondition({ columns: posColumn, where: { tid: ctx.tender.id } });
+            const posData = ctx.stage.ledgerHis
+                ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.pos_file)
+                : await ctx.service.pos.getAllDataByCondition({ columns: this.posColumn, where: { tid: ctx.tender.id } });
+            const extraData = await ctx.service.posExtra.getData(ctx.tender.id, this.posExtraColumn);
             // 根据当前人,或指定对象查询数据
             if (ctx.stage.readOnly) {
                 curStageData = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id,
@@ -294,8 +314,9 @@ module.exports = app => {
             // 查询截止上期数据
             const preStageData = ctx.stage.order > 1 ? await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(posData, [
-                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
-                { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
+                { data: extraData, fields: this.posExtraColumn, prefix: '', relaId: 'id'},
+                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'pid' },
+                { data: preStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid' },
             ]);
             return posData;
         }
@@ -320,23 +341,23 @@ module.exports = app => {
                 const responseData = { err: 0, msg: '', data: {}, hpack: [] };
                 const hpack = true;
                 const sjsRela = await this.ctx.service.project.getSjsRela(ctx.session.sessionProject.id);
-                const [ledgerColumn, posColumn] = this._getLedgerColumn(sjsRela);
+                this._getLedgerColumn(sjsRela);
                 for (const f of filter) {
                     switch (f) {
                         case 'ledger':
                             if (hpack) {
                                 responseData.hpack.push('ledgerData');
-                                responseData.data.ledgerData = this.ctx.helper.hpackArr(await this._getStageLedgerData(ctx, ledgerColumn));
+                                responseData.data.ledgerData = this.ctx.helper.hpackArr(await this._getStageLedgerData(ctx));
                             } else {
-                                responseData.data.ledgerData = await this._getStageLedgerData(ctx, ledgerColumn);
+                                responseData.data.ledgerData = await this._getStageLedgerData(ctx);
                             }
                             break;
                         case 'pos':
                             if (hpack) {
                                 responseData.hpack.push('posData');
-                                responseData.data.posData = this.ctx.helper.hpackArr(await this._getStagePosData(ctx, posColumn));
+                                responseData.data.posData = this.ctx.helper.hpackArr(await this._getStagePosData(ctx));
                             } else {
-                                responseData.data.posData = await this._getStagePosData(ctx, posColumn);
+                                responseData.data.posData = await this._getStagePosData(ctx);
                             }
                             break;
                         case 'detail':
@@ -389,6 +410,7 @@ module.exports = app => {
 
         async check(ctx) {
             try {
+                this._getLedgerColumn();
                 const ledgerData = await this._getStageLedgerData(ctx);
                 const posData = await this._getStagePosData(ctx);
 
@@ -439,8 +461,8 @@ module.exports = app => {
                     preStageData = [];
                 }
                 this.ctx.helper.assignRelaData(responseData.data, [
-                    { data: curStageData, fields: ['contract_qty', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
-                    { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
+                    { data: curStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'pid' },
+                    { data: preStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid' },
                 ]);
                 ctx.body = responseData;
             } catch (err) {
@@ -500,7 +522,8 @@ module.exports = app => {
                 }
                 const bills = data.bills ? data.bills : await ctx.service.ledger.getDataById(data.pos.lid);
                 const pos = data.pos;
-                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, bills);
+                const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
+                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, data, projectFunInfo.minusNoValue && ctx.tender.info.fun_rela.stage_change.minusNoValue);
                 const useChanges = ctx.stage.readOnly
                     ? await ctx.service.stageChange.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder, bills.id, pos ? pos.id : -1)
                     : await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);
@@ -523,14 +546,14 @@ module.exports = app => {
                 if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
                     throw '调用变更令数据错误';
                 }
-                let result, minus, posMinus;
+                let result;
                 if (data.target.pos) {
-                    result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
+                    result = await ctx.service.stageChange.posChange(data.target.pos, data.target.minus, data.change);
                     result.change = { target: { lid: data.target.pos.lid, pid: data.target.pos.id } };
                     result.change.data = await ctx.service.stageChange.getLastestStageData(ctx.tender.id,
                         ctx.stage.id, data.target.pos.lid, data.target.pos.id);
                 } else {
-                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
+                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.target.minus, data.change);
                     result.change = { target: { lid: data.target.bills.id, pid: '-1' } };
                     result.change.data = await ctx.service.stageChange.getLastestStageData(ctx.tender.id,
                         ctx.stage.id, data.target.bills.id, '-1');
@@ -1365,10 +1388,10 @@ module.exports = app => {
                 if (data.main) {
                     result.main = {};
                     result.main.ledger = ctx.stage.ledgerHis
-                        ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
+                        ? await ctx.helper.loadLedgerDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
                         : await ctx.service.ledger.getData(ctx.tender.id);
                     result.main.pos = ctx.stage.ledgerHis
-                        ? await ctx.service.pos.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
+                        ? await ctx.helper.loadLedgerDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
                         : await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                 }
                 for (const order of data.roles) {
@@ -1405,6 +1428,7 @@ module.exports = app => {
 
         async loadBwtz(ctx) {
             try {
+                this._getLedgerColumn();
                 const data = ctx.request.body.data ? JSON.parse(ctx.request.body.data) : {};
                 const ledgerData = await this._getStageLedgerData(ctx);
                 const posData = await this._getStagePosData(ctx);

+ 9 - 5
app/lib/analysis_excel.js

@@ -901,8 +901,9 @@ class AnalysisStageExcelTree extends AnalysisExcelTree {
             contract_tp: {value: ['本期合同计量|金额'], type: colDefineType.match},
             deal_dgn_qty1: {value: ['合同|项目节数量1'], type: colDefineType.match},
             deal_dgn_qty2: {value: ['合同|项目节数量2'], type: colDefineType.match},
-            qc_dgn_qty1: {value: ['变更|项目节数量1'], type: colDefineType.match},
-            qc_dgn_qty2: {value: ['变更|项目节数量2'], type: colDefineType.match},
+            c_dgn_qty1: {value: ['变更|项目节数量1'], type: colDefineType.match},
+            c_dgn_qty2: {value: ['变更|项目节数量2'], type: colDefineType.match},
+            postil: {value: ['本期批注'], type: colDefineType.match}
         };
         this.needCols = ['code', 'b_code', 'pos', 'name', 'unit', 'unit_price', 'contract_qty', 'contract_tp'];
     }
@@ -942,6 +943,7 @@ class AnalysisStageExcelTree extends AnalysisExcelTree {
             xmj.deal_dgn_qty2 = aeUtils.toNumber(row[this.colsDef.deal_dgn_qty2]);
             xmj.c_dgn_qty1 = aeUtils.toNumber(row[this.colsDef.c_dgn_qty1]);
             xmj.c_dgn_qty2 = aeUtils.toNumber(row[this.colsDef.c_dgn_qty2]);
+            xmj.postil = this.ctx.helper.replaceReturn(row[this.colsDef.postil]);
             this.ctx.helper.checkDgnQtyPrecision(xmj);
             return xmj;
         } catch (error) {
@@ -973,12 +975,13 @@ class AnalysisStageExcelTree extends AnalysisExcelTree {
         node.unit_price = this.ctx.helper.round(aeUtils.toNumber(row[this.colsDef.unit_price]), this.decimal.up);
         const precision = this.ctx.helper.findPrecision(this.precision, node.unit);
         node.contract_qty = this.ctx.helper.round(aeUtils.toNumber(row[this.colsDef.contract_qty]), precision.value);
-        if (node.quantity && node.unit_price) {
-            node.contract_tp = this.ctx.helper.mul(node.quantity, node.unit_price, this.decimal.tp);
+        if (node.contract_qty && node.unit_price) {
+            node.contract_tp = this.ctx.helper.mul(node.contract_qty, node.unit_price, this.decimal.tp);
         } else {
             node.contract_tp = null;
         }
-        if (this.filter.filterZeroGcl && !node.quantity && !node.total_price) return true;
+        node.postil = this.ctx.helper.replaceReturn(row[this.colsDef.postil]);
+        if (this.filter.filterZeroGcl && !node.contract_qty && !node.contract_tp) return true;
         return this.cacheTree.addGclNode(node);
     }
     /**
@@ -994,6 +997,7 @@ class AnalysisStageExcelTree extends AnalysisExcelTree {
         pos.quantity = aeUtils.toNumber(row[this.colsDef.contract_qty]);
         pos = this.cacheTree.addPos(pos, true);
         pos.contract_qty = pos.quantity;
+        pos.postil = this.ctx.helper.replaceReturn(row[this.colsDef.postil]);
         return pos;
     }
 

+ 1 - 1
app/lib/rptCustomData.js

@@ -304,7 +304,7 @@ class jhHelper {
         this.ctx.helper.saveBufferFile(JSON.stringify(stageChangeDetail, '', '\t'), this.ctx.app.baseDir + '/temp.json');
         for (const dc of gsDefine.defaultCompare) {
             if (!auditors[dc]) continue;
-             const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder', auditors[dc].times, auditors[dc].order);
+             const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder', auditors[dc].times, auditors[dc].order);
             this._loadChangeDetail(billsIndex, scd, gsDefine, `r${dc}_`);
             this.prefixes.push(`r${dc}_`);
         }

+ 10 - 8
app/lib/sum_load.js

@@ -210,7 +210,7 @@ class loadLedgerGclTree extends loadGclBaseTree {
 }
 
 class updateReviseGclTree extends loadGclBaseTree {
-    constructor (ctx, setting) {
+    constructor(ctx, setting) {
         super(ctx, setting);
         this.errors = [];
     }
@@ -308,14 +308,14 @@ class updateReviseGclTree extends loadGclBaseTree {
                 deal_qty: i.deal_qty, deal_tp: i.deal_tp || 0,
                 sgfh_qty: i.sgfh_qty, sjcl_qty: i.sjcl_qty, qtcl_qty: i.qtcl_qty, quantity: i.quantity,
                 sgfh_tp: i.sgfh_tp || 0, sjcl_tp: i.sjcl_tp || 0, qtcl_tp: i.qtcl_tp || 0, total_price: i.total_price || 0,
-            })
+            });
         }
         return result;
     }
 }
 
 class gatherStageGclTree extends loadGclBaseTree {
-    constructor (ctx, setting) {
+    constructor(ctx, setting) {
         super(ctx, setting);
         this.cover = setting.cover;
     }
@@ -369,7 +369,7 @@ class gatherStageGclTree extends loadGclBaseTree {
     gather(source, parent) {
         parent = parent ? parent : this.parent;
         const checkFun = function (node, source) {
-            return  (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
+            return (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
         };
         const node = this.ignoreParent ? this.addNodeWithoutParent(source, checkFun) : this.addNode(source, parent, checkFun);
         if (node.is_tp) {
@@ -420,7 +420,7 @@ class gatherStageGclTree extends loadGclBaseTree {
 }
 
 class sumLoad {
-    constructor (ctx) {
+    constructor(ctx) {
         this.ctx = ctx;
     }
 
@@ -524,13 +524,15 @@ class sumLoad {
             parent: select, maxId, type: 'ledger', defaultData, ignoreParent, cover,
         });
         const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
+        const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
         const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
         const importLid = await this.ctx.service.stageImportChange.getLeafXmjImportLid(this.ctx.stage.id, select.id);
         this.ctx.helper.assignRelaData(posterity, [
-            { data: importLid, fields: [ 'is_import' ], prefix: '', relaId: 'lid' },
-            { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp' ], prefix: '', relaId: 'lid' },
+            { data: extraData, fields: ['is_import'], prefix: '', relaId: 'id' },
+            { data: importLid, fields: ['is_import'], prefix: '', relaId: 'lid' },
+            { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
         ]);
-        const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
+        const pos = await this.ctx.service.pos.getData(this.ctx.tender.id);
         this.loadTree.loadBase(posterity, pos);
 
         for (const tender of tenders) {

+ 2 - 1
app/public/css/main.css

@@ -1059,7 +1059,8 @@ label{
   font-size:100%;
 }
 .modal-header{
-  padding:.5rem 1rem
+  padding:.5rem 1rem;
+  cursor: move;
 }
 .modal-title{
   font-size:16px;

+ 4 - 0
app/public/js/budget_compare.js

@@ -35,6 +35,10 @@ $(document).ready(() => {
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
         readOnly: true,
+        frozenColCount: 3,
+        frozenLineColor: '#93b5e4',
+        localCache: { key: 'budget-compare', colWidth: true },
+
     };
     sjsSettingObj.setFxTreeStyle(spreadSetting, sjsSettingObj.FxTreeStyle.jz);
     SpreadJsObj.initSheet(compareSheet, spreadSetting);

+ 3 - 1
app/public/js/gcl_gather.js

@@ -39,6 +39,7 @@ const gclGatherModel = (function () {
 
     const gclList = [], leafXmjs = [];
     const mergeChar = ';';
+    let tpDecimal = 0;
 
     /**
      * 将所有数据加载至树结构
@@ -70,8 +71,9 @@ const gclGatherModel = (function () {
         deal = dealBills;
     }
 
-    function loadChangeBillsData(data) {
+    function loadChangeBillsData(data, decimal) {
         change = data;
+        tpDecimal = decimal;
     }
 
     function gatherfields(obj, src, fields) {

+ 17 - 6
app/public/js/ledger.js

@@ -986,23 +986,34 @@ $(document).ready(function() {
             const select = SpreadJsObj.getSelectObject(sheet);
             if (!select || !select.code) return;
 
-            const recursiveSortCode = function (data, parentCode, children) {
+            const getChildSort = function (i, split) {
+                if (i <= 0) throw '参数错误';
+                switch(split) {
+                    case '0':
+                        return i < 10 ? split + i : i + '';
+                    case '-':
+                    default:
+                        return split + i;
+                }
+            };
+
+            const recursiveSortCode = function (data, parentCode, children, split) {
                 if (!children || children.length === 0) return;
 
                 for (const [i, child] of children.entries()) {
                     if (!child.b_code || child.b_code === '') {
-                        const code = parentCode + '-' + (i + 1);
+                        const code = parentCode + getChildSort(i + 1, split);
                         const cData = tree.getNodeKeyData(child);
                         cData.code = code;
                         data.push(cData);
                         if (!tree.isLeafXmj(child)) {
-                            recursiveSortCode(data, code, child.children);
+                            recursiveSortCode(data, code, child.children, split);
                         }
                     }
                 }
             };
             const data = [];
-            recursiveSortCode(data, select.code, select.children);
+            recursiveSortCode(data, select.code, select.children, tree.getCodeSplit());
             if (data.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
                     const refreshNode = tree.loadPostData(result);
@@ -1420,12 +1431,12 @@ $(document).ready(function() {
             icon: 'fa-sort-numeric-asc',
             disabled: function (key, opt) {
                 const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                return !node || !node.code || !node.children || node.children === 0 || node.code.indexOf('-') < 0;
+                return !node || !node.code || !node.children || node.children === 0 || node.code.length < 3;
             },
             callback: function (key, opt) {
                 treeOperationObj.sortCode(ledgerSpread.getActiveSheet());
             },
-            visible: function (key, opt) {;
+            visible: function (key, opt) {
                 return !readOnly;
             }
         };

+ 17 - 0
app/public/js/path_tree.js

@@ -1023,6 +1023,23 @@ const createNewPathTree = function (type, setting) {
                 return false;
             })
         }
+
+        checkCodeType() {
+            for (const node of this.nodes) {
+                if (!node.code) continue;
+
+                if (node.code.indexOf('-') >= 0) {
+                    return '07';
+                } else if (node.code.length > 5) {
+                    const num = _.toNumber(node.code);
+                    if (num && num > 10000) return '18';
+                }
+            }
+            return '18';
+        }
+        getCodeSplit() {
+            return this.checkCodeType() === '07' ? '-' : '0';
+        }
     }
 
     class LedgerTree extends FxTree {

+ 13 - 1
app/public/js/shares/sjs_setting.js

@@ -80,5 +80,17 @@ const sjsSettingObj = (function () {
             }
         }
     };
-    return {setFxTreeStyle, FxTreeStyle, setGridSelectStyle, setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat, setPropValue, set3FCols};
+    const setQcCols = function (cols, rela){
+        for (const r of rela) {
+            const col = _.find(cols, {field: r.field});
+            if (!col) continue;
+
+            col.readOnly = true;
+            col.cellType = 'activeImageBtn';
+            col.normalImg = '#ellipsis-icon';
+            col.indent = 5;
+            col.showImage = r.showImage;
+        }
+    };
+    return {setFxTreeStyle, FxTreeStyle, setGridSelectStyle, setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat, setPropValue, set3FCols, setQcCols};
 })();

+ 13 - 9
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -304,15 +304,17 @@ const SpreadJsObj = {
      * @param {GC.Spread.Sheets.Worksheet} sheet
      */
     _initSheetHeader: function (sheet) {
-        if (!sheet.zh_setting || !sheet.zh_setting.cols) { return; }
+        const setting = sheet.zh_setting;
+        if (!setting || !setting.cols) { return; }
 
-        sheet.setColumnCount(sheet.zh_setting.cols.length);
-        sheet.setRowCount(sheet.zh_setting.headRows, spreadNS.SheetArea.colHeader);
-        for (let iRow = 0; iRow < sheet.zh_setting.headRowHeight.length; iRow ++) {
-            sheet.setRowHeight(iRow, sheet.zh_setting.headRowHeight[iRow], spreadNS.SheetArea.colHeader);
+
+        sheet.setColumnCount(setting.cols.length);
+        sheet.setRowCount(setting.headRows, spreadNS.SheetArea.colHeader);
+        for (let iRow = 0; iRow < setting.headRowHeight.length; iRow ++) {
+            sheet.setRowHeight(iRow, setting.headRowHeight[iRow], spreadNS.SheetArea.colHeader);
         }
-        for (let iCol = 0; iCol < sheet.zh_setting.cols.length; iCol++) {
-            const col = sheet.zh_setting.cols[iCol];
+        for (let iCol = 0; iCol < setting.cols.length; iCol++) {
+            const col = setting.cols[iCol];
             const title = col.title.split('|');
             const colSpan = col.colSpan ? col.colSpan.split('|'): ['1'], rowSpan = col.rowSpan ? col.rowSpan.split('|'): ['1'];
             for (let i = 0; i < title.length; i++) {
@@ -329,9 +331,11 @@ const SpreadJsObj = {
         }
         sheet.rowOutlines.direction(spreadNS.Outlines.OutlineDirection.backward);
         sheet.showRowOutline(false);
-        if (sheet.zh_setting.defaultRowHeight) {
-            sheet.defaults.rowHeight = sheet.zh_setting.defaultRowHeight;
+        if (setting.defaultRowHeight) {
+            sheet.defaults.rowHeight = setting.defaultRowHeight;
         }
+        if (setting.frozenLineColor) sheet.options.frozenlineColor = setting.frozenLineColor;
+        if (setting.frozenColCount) sheet.frozenColumnCount(setting.frozenColCount);
     },
     reinitSheetHeader: function (sheet) {
         this.beginMassOperation(sheet);

+ 6 - 0
app/public/js/sr_detail.js

@@ -894,6 +894,8 @@ $(document).ready(() => {
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量金额');
                 $('[name=type-title-qc]').text('本期变更计量金额');
+                $('#show-qc-minus-jl').parent().hidden();
+                $('#qc-minus-jl').parent().hidden();
             } else {
                 const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                 jlCol.title = '本期计量数量';
@@ -967,6 +969,10 @@ $(document).ready(() => {
             $('#show-qc-jl').text(qcJl);
             $('#qc-jl').val(qcJl);
 
+            const qcMinusJl = data && data.qc_minus_jl ? data.qc_minus_jl : '';
+            $('#show-qc-minus-jl').text(qcMinusJl);
+            $('#qc-jl-minus-jl').val(qcMinusJl);
+
             const bglCode = data && data.bgl_code ? data.bgl_code : '';
             $('#show-bgl-code').text(bglCode);
             $('#bgl-code').val(bglCode);

+ 48 - 30
app/public/js/stage.js

@@ -32,7 +32,7 @@ function getExprInfo (field) {
 function customColDisplay () {
     const defaultSetting = [
         { title: '本期计量合同', fields: ['contract_qty', 'contract_tp'], visible: true },
-        { title: '本期数量变更', fields: ['qc_qty', 'qc_tp', 'qc_bgl'], visible: true },
+        { title: '本期数量变更', fields: ['qc_qty', 'qc_tp', 'qc_bgl', 'qc_minus_qty'], visible: true },
         { title: '本期完成计量', fields: ['gather_qty', 'gather_tp'], visible: true },
         { title: '截止本期计量合同', fields: ['end_contract_qty', 'end_contract_tp'], visible: true },
         { title: '截止本期数量变更', fields: ['end_qc_qty', 'end_qc_tp', 'end_qc_bgl'], visible: true },
@@ -65,7 +65,7 @@ function customizeStageTreeSetting(setting, customDisplay) {
     for (const cd of customDisplay) {
         for (const c of setting.cols) {
             if (cd.fields.indexOf(c.field) !== -1) {
-                c.visible = cd.visible;
+                c.visible = c.defaultVisible === undefined ? cd.visible : c.defaultVisible && cd.visible;
             }
         }
     }
@@ -226,7 +226,7 @@ $(document).ready(() => {
         empty_code: { enable: 0 },
         calc: {
             enable: 1,
-            fields: ['contract_qty', 'qc_qty'],
+            fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'],
         },
         zero: { enable: 0 },
         tp: {
@@ -267,7 +267,7 @@ $(document).ready(() => {
         markExpandSubKey: window.location.pathname.split('/')[2],
     };
     // 台账树结构计算相关设置
-    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil', 'used', 'contract_expr'];
     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', 'end_correct_tp'];
     stageTreeSetting.calcFun = function (node) {
@@ -276,6 +276,7 @@ $(document).ready(() => {
             node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
             node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
             node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
+            node.end_qc_minus_qty = ZhCalc.add(node.pre_qc_minus_qty, node.qc_minus_qty);
             node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
         }
         node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
@@ -300,13 +301,14 @@ $(document).ready(() => {
     // 初始化 计量单元 数据结构
     const stagePosSetting = {
         id: 'id', ledgerId: 'lid',
-        updateFields: ['contract_qty', 'qc_qty', 'postil', 'contract_expr'],
+        updateFields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'postil', 'contract_expr'],
     };
     stagePosSetting.calcFun = function (pos) {
         pos.pre_gather_qty = ZhCalc.add(pos.pre_contract_qty, pos.pre_qc_qty);
         pos.gather_qty = ZhCalc.add(pos.contract_qty, pos.qc_qty);
         pos.end_contract_qty = ZhCalc.add(pos.pre_contract_qty, pos.contract_qty);
         pos.end_qc_qty = ZhCalc.add(pos.pre_qc_qty, pos.qc_qty);
+        pos.end_qc_minus_qty = ZhCalc.add(pos.pre_qc_minus_qty, pos.qc_minus_qty);
         pos.end_gather_qty = ZhCalc.add(pos.pre_gather_qty, pos.gather_qty);
         pos.sum = ZhCalc.add(pos.end_qc_qty, pos.quantity);
         pos.end_gather_percent = ZhCalc.mul(ZhCalc.div(pos.end_gather_qty, pos.sum), 100, 2);
@@ -413,10 +415,7 @@ $(document).ready(() => {
             // 切换变更令,加载右侧明细数据
             this.spread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
                 const change = SpreadJsObj.getSelectObject(info.sheet);
-                console.log(change);
-                if(change) {
-                    self._loadChangeDetail(change);
-                }
+                if(change) self._loadChangeDetail(change);
             });
             // 填写本期计量
             this.spread.bind(spreadNS.Events.EditEnded, function (e, info) {
@@ -528,7 +527,7 @@ $(document).ready(() => {
             for (const c of this.changes) {
                 c.bamount = _.toNumber(c.b_amount);
                 c.vamount = ZhCalc.sub(ZhCalc.sub(c.bamount, c.used_amount), c.stage_used_amount);
-                const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid});
+                const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid, no_value: this.callData.noValue});
                 if (uc) {
                     c.org_uamount = uc.qty;
                     c.uamount = uc.qty;
@@ -639,12 +638,7 @@ $(document).ready(() => {
     const slSpread = SpreadJsObj.createNewSpread($('#stage-ledger')[0]);
     customizeStageTreeSetting(ledgerSpreadSetting, customColDisplay());
     // 数量变更列,添加按钮
-    const qcCol = _.find(ledgerSpreadSetting.cols, {field: 'qc_qty'});
-    qcCol.readOnly = true;
-    qcCol.cellType = 'activeImageBtn';
-    qcCol.normalImg = '#ellipsis-icon';
-    qcCol.indent = 5;
-    qcCol.showImage = function (data) {
+    const qcColShowImage = function (data) {
         if (!data || (data.children && data.children.length > 0) || !(data.b_code && data.b_code !== '')) {
             return false;
         } else {
@@ -652,6 +646,10 @@ $(document).ready(() => {
             return !(nodePos && nodePos.length > 0);
         }
     };
+    sjsSettingObj.setQcCols(ledgerSpreadSetting.cols, [
+        {field: 'qc_qty', showImage: qcColShowImage},
+        {field: 'qc_minus_qty', showImage: qcColShowImage},
+    ]);
     const ratioCol = ledgerSpreadSetting.cols.find(x => {return x.field === 'end_gather_percent' || x.field === 'end_correct_percent'});
     if (ratioCol) ratioCol.field = tenderInfo.display.stage.correct ? 'end_correct_percent' : 'end_gather_percent';
     ledgerSpreadSetting.imageClick = function (data, hitinfo) {
@@ -660,10 +658,12 @@ $(document).ready(() => {
             case 'dagl': data.dagl_url && window.open(data.dagl_url); break;
             case 'gxby': data.gxby_url && window.open(data.gxby_url); break;
             case 'qc_qty':
+            case 'qc_minus_qty':
                 if (data.children && data.children.length > 0 || data.lock || data.is_import) return;
                 const nodePos = stagePos.getLedgerPos(data.id);
                 if (nodePos && nodePos.length > 0) return;
-                changesObj.loadChanges({bills: data});
+                const minus = col.field === 'qc_minus_qty' ? 1 : 0;
+                changesObj.loadChanges({bills: data, minus, noValue: minus});
                 break;
             default: return;
         }
@@ -729,31 +729,30 @@ $(document).ready(() => {
         return data.lock || false;
     };
     SpreadJsObj.initSheet(slSpread.getActiveSheet(), ledgerSpreadSetting);
-    slSpread.getActiveSheet().frozenColumnCount(5);
-    slSpread.getActiveSheet().options.frozenlineColor = '#93b5e4';
 
     //初始化所有附件列表
     getAllList();
 
     // 初始化 计量单元 Spread
     const spSpread = SpreadJsObj.createNewSpread($('#stage-pos')[0]);
-    const spCol = _.find(posSpreadSetting.cols, {field: 'qc_qty'});
-    spCol.readOnly = true;
-    spCol.cellType = 'activeImageBtn';
-    spCol.normalImg = '#ellipsis-icon';
-    spCol.indent = 5;
-    spCol.showImage = function (data) {
+    const posQcColShowImage = function (data) {
         return data !== undefined && data !== null;
     };
+    sjsSettingObj.setQcCols(posSpreadSetting.cols, [
+        { field: 'qc_qty', showImage: posQcColShowImage },
+        { field: 'qc_minus_qty', showImage: posQcColShowImage }
+    ]);
     posSpreadSetting.imageClick = function (data, hitinfo) {
         const col = hitinfo.sheet.zh_setting.cols[hitinfo.col];
         switch (col.field) {
             case 'gxby': data.gxby_url && window.open(data.gxby_url); break;
             case 'dagl': data.dagl_url && window.open(data.dagl_url); break;
             case 'qc_qty':
+            case 'qc_minus_qty':
                 const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
                 if (node.lock) return;
-                changesObj.loadChanges({bills: node, pos: data});
+                const minus = col.field === 'qc_minus_qty' ? 1 : 0;
+                changesObj.loadChanges({bills: node, pos: data, minus, noValue: minus});
                 break;
             default: return;
         }
@@ -992,7 +991,7 @@ $(document).ready(() => {
                 const validCols = [];
                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
                     const colSetting = sheet.zh_setting.cols[iCol];
-                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty') {
+                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty' && colSetting.field !== 'minus_qc_qty') {
                         validCols.push(iCol);
                     }
                 }
@@ -1068,7 +1067,7 @@ $(document).ready(() => {
             if (info.sheet.zh_setting) {
                 const setting = info.sheet.zh_setting;
                 const range = info.cellRange;
-                const validField = ['contract_qty', 'contract_tp', 'qc_qty', 'postil'].concat(['memo', 'ex_memo1', 'ex_memo2', 'ex_memo3'], setting.dgnUpFields);
+                const validField = ['contract_qty', 'contract_tp', 'qc_qty', 'minus_qc_qty', 'postil'].concat(['memo', 'ex_memo1', 'ex_memo2', 'ex_memo3'], setting.dgnUpFields);
                 for (let iCol = range.col; iCol < range.col + range.colCount; iCol++) {
                     const col = info.sheet.zh_setting.cols[iCol];
                     if ((validField.indexOf(col.field) === -1)) {
@@ -1247,6 +1246,7 @@ $(document).ready(() => {
             switch (col.field) {
                 case 'contract_qty':
                 case 'qc_qty':
+                case 'qc_minus_qty':
                     info.cancel = node.is_tp;
                     break;
                 case 'contract_tp':
@@ -1771,7 +1771,7 @@ $(document).ready(() => {
             if (info.sheet.zh_setting) {
                 const sortData = info.sheet.zh_data;
                 const range = info.cellRange;
-                const validField = ['contract_qty', 'qc_qty', 'postil', 'real_qty', 'ex_memo1', 'ex_memo2', 'ex_memo3'];
+                const validField = ['contract_qty', 'qc_qty', 'minus_qc_qty', 'postil', 'real_qty', 'ex_memo1', 'ex_memo2', 'ex_memo3'];
                 if (!checkTzMeasureType()) {
                     validField.push('name', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'position', 'drawing_code');
                 }
@@ -1930,7 +1930,7 @@ $(document).ready(() => {
                 const validCols = [];
                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
                     const colSetting = sheet.zh_setting.cols[iCol];
-                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty') {
+                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty' && colSetting.field !== 'minus_qc_qty') {
                         validCols.push(iCol);
                     }
                 }
@@ -2907,12 +2907,16 @@ $(document).ready(() => {
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量金额');
                 $('[name=type-title-qc]').text('本期变更计量金额');
+                $('#show-qc-minus-jl').parent().hide();
+                $('#qc-minus-jl').parent().hide();
             } else {
                 const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                 jlCol.title = '本期计量数量';
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量数量');
                 $('[name=type-title-qc]').text('本期变更计量数量');
+                $('#show-qc-minus-jl').parent().show();
+                $('#qc-minus-jl').parent().show();
             }
             if (stage.im_type === imType.bb.value || stage.im_type === imType.bw.value) {
                 $('#show-jldy').parent().show();
@@ -3002,12 +3006,16 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadSheetHeader(self.sheet);
                         $('[name=type-title-contract]').text('本期合同计量金额');
                         $('[name=type-title-qc]').text('本期变更计量金额');
+                        $('#show-qc-minus-jl').parent().hide();
+                        $('#qc-minus-jl').parent().hide();
                     } else {
                         const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                         jlCol.title = '本期计量数量';
                         SpreadJsObj.reLoadSheetHeader(self.sheet);
                         $('[name=type-title-contract]').text('本期合同计量数量');
                         $('[name=type-title-qc]').text('本期变更计量数量');
+                        $('#show-qc-minus-jl').parent().show();
+                        $('#qc-minus-jl').parent().show();
                     }
                     if (stage.im_type === imType.bb.value || stage.im_type === imType.bw.value) {
                         $('#show-jldy').parent().show();
@@ -3595,6 +3603,10 @@ $(document).ready(() => {
             $('#show-qc-jl').text(qcJl);
             $('#qc-jl').val(qcJl);
 
+            const qcMinusJl = data && data.qc_minus_jl ? data.qc_minus_jl : '';
+            $('#show-qc-minus-jl').text(qcMinusJl);
+            $('#qc-minus-jl').val(qcMinusJl);
+
             const bglCode = data && data.bgl_code ? data.bgl_code : '';
             $('#show-bgl-code').text(bglCode);
             $('#bgl-code').val(bglCode);
@@ -3749,6 +3761,12 @@ $(document).ready(() => {
                                 const node = stageTree.nodes.find(x => {return x.id === changeBills.gcl_id});
                                 SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), node.ledger_id, true);
                                 stagePosSpreadObj.loadCurPosData();
+                                console.log(changeBills);
+                                const posData = spSpread.getActiveSheet().zh_data;
+                                if (!posData || posData.length === 0) return;
+
+                                const changePos = posData.find(x => { return x.name === changeBills.bwmx; });
+                                if (changePos) SpreadJsObj.locateData(spSpread.getActiveSheet(), changePos);
                             } else {
                                 const cb = {
                                     b_code: changeBills.code || '',

+ 1 - 1
app/public/js/stage_gather.js

@@ -129,7 +129,7 @@ $(document).ready(function () {
         gclGatherModel.loadLedgerData(result.ledgerData);
         gclGatherModel.loadPosData(result.posData);
         gclGatherModel.loadDealBillsData(result.dealBills);
-        gclGatherModel.loadChangeBillsData(result.changeBills);
+        gclGatherModel.loadChangeBillsData(result.changeBills, tenderDecimal.tp);
         gclGatherData = gclGatherModel.gatherGclData();
         gclGatherModel.checkDiffer(gclGatherData);
         checkOverRange(gclGatherData);

+ 33 - 25
app/public/js/stage_im.js

@@ -24,8 +24,8 @@ const stageIm = (function () {
         keys: ['id', 'tender_id', 'ledger_id'],
         stageId: 'id',
     };
-    gsTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'];
-    gsTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
+    gsTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'];
+    gsTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'qc_minus_qty', 'gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
     gsTreeSetting.calcFun = function (node) {
         if (node.children && node.children.length === 0) {
             node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
@@ -389,10 +389,10 @@ const stageIm = (function () {
         if (im.calc_memo !== undefined && im.calc_memo !== null && im.calc_memo !== '') return;
 
         if (im.leafXmjs && im.leafXmjs.length > 0) {
-            const memo = ['本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit];
+            const memo = ['本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit];
             for (const lx of im.leafXmjs) {
                 for (const p of lx.pos) {
-                    memo.push(p.name + ':' + p.jl + ' ' + im.unit);
+                    memo.push(p.name + ':' + p.jl + (p.qc_minus_jl ? (` (不计价 ${p.qc_minus_jl}) `) : ' ') + im.unit);
                 }
             }
             im.calc_memo = memo.join('\n');
@@ -405,10 +405,10 @@ const stageIm = (function () {
                 if (b.pos && b.pos.length > 0) {
                     memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name);
                     for (const p of b.pos) {
-                        memo.push(p.name + ':' + p.jl + ' ' + b.unit);
+                        memo.push(p.name + ':' + p.jl + (p.qc_minus_jl ? (` (不计价 ${p.qc_minus_jl}) `) : ' ') + b.unit);
                     }
                 } else {
-                    memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name + ':' + (checkZero(b.jl) ? 0 : b.jl) + ' ' + b.unit);
+                    memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name + ':' + (checkZero(b.jl) ? 0 : b.jl) + (b.qc_minus_jl ? (` (不计价 ${b.qc_minus_jl}) `) : ' ') + b.unit);
                 }
             }
             im.calc_memo = memo.join('\n');
@@ -457,7 +457,7 @@ const stageIm = (function () {
         const posRange = gsPos.getLedgerPos(node.id);
         if (!posRange) { return }
         for (const p of posRange) {
-            if (checkZero(p.contract_qty) && checkZero(p.qc_qty)) { continue; }
+            if (checkZero(p.contract_qty) && checkZero(p.qc_qty) && checkZero(p.qc_minus_qty)) { continue; }
             let lp = _.find(gclBills.pos, {name: p.name});
             if (!lp) {
                 lp = {name: p.name};
@@ -466,6 +466,7 @@ const stageIm = (function () {
             lp.jl = ZhCalc.add(lp.jl, p.gather_qty);
             lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty);
             lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty);
+            lp.qc_minus_jl = ZhCalc.add(lp.qc_minus_jl, p.qc_minus_qty);
         }
     }
     function recursiveGenerateTzGclBills(node, im) {
@@ -477,7 +478,7 @@ const stageIm = (function () {
                     continue;
                 }
                 if (checkZero(p.contract_qty) && checkZero(p.contract_tp) &&
-                    checkZero(p.qc_qty) && checkZero(p.qc_tp)) {
+                    checkZero(p.qc_qty) && checkZero(p.qc_tp) && checkZero(p.qc_minus_qty)) {
                     continue;
                 }
                 let b = _.find(im.gclBills, {bid: p.id});
@@ -488,6 +489,7 @@ const stageIm = (function () {
                 b.jl = ZhCalc.add(b.jl, p.gather_qty);
                 b.contract_jl = ZhCalc.add(b.contract_jl, p.contract_qty);
                 b.qc_jl = ZhCalc.add(b.qc_jl, p.qc_qty);
+                b.qc_minus_jl = ZhCalc.add(b.qc_minus_jl, p.qc_minus_qty);
                 generateTzPosData(p, b);
             }
         }
@@ -533,23 +535,23 @@ const stageIm = (function () {
             for (const p of posterity) {
                 if (p.children && p.children.length > 0) continue;
                 if (!checkZero(p.contract_qty) || !checkZero(p.contract_tp) ||
-                    !checkZero(p.qc_qty) || !checkZero(p.qc_tp))
+                    !checkZero(p.qc_qty) || !checkZero(p.qc_tp) || !checkZero(p.qc_minus_qty))
                     return true;
                 const pPos = gsPos.getLedgerPos(p.id);
                 if (!pPos || pPos.length === 0) continue;
                 for (const pp of pPos) {
-                    if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+                    if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return true;
                 }
             }
             return false;
         } else {
             if (!checkZero(node.contract_qty) || !checkZero(node.contract_tp) ||
-                !checkZero(node.qc_qty) || !checkZero(node.qc_tp))
+                !checkZero(node.qc_qty) || !checkZero(node.qc_tp) || !checkZero(node.qc_minus_qty))
                 return true;
             const pPos = gsPos.getLedgerPos(node.id);
             if (!pPos || pPos.length === 0) return false;
             for (const pp of pPos) {
-                if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+                if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return true;
             }
         }
     }
@@ -558,7 +560,7 @@ const stageIm = (function () {
         const pPos = gsPos.getLedgerPos(node.id);
         if (!pPos || pPos.length === 0) return null;
         for (const pp of pPos) {
-            if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return pp;
+            if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return pp;
         }
     }
 
@@ -587,7 +589,7 @@ const stageIm = (function () {
             const peg = getPegNode(node);
             const im = {
                 lid: node.id, pid: '', code: node.code,
-                jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp,
+                jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp, qc_minus_jl: 0,
                 //im_code: getNewImCode(),
                 peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
                 position: '',
@@ -625,11 +627,13 @@ const stageIm = (function () {
         }
         gcl.contract_jl = ZhCalc.add(gcl.contract_jl, bills.contract_jl);
         gcl.qc_jl = ZhCalc.add(gcl.qc_jl, bills.qc_jl);
+        gcl.qc_minus_jl = ZhCalc.add(gcl.qc_minus_jl, bills.qc_minus_jl);
         gcl.jl = ZhCalc.add(gcl.jl, bills.jl);
     }
     function calculateBwBillsIm(im) {
         im.contract_jl = 0;
         im.qc_jl = 0;
+        im.qc_minus_jl = 0;
         for (const b of im.gclBills) {
             im.contract_jl = ZhCalc.add(im.contract_jl, ZhCalc.mul(b.contract_jl, b.unit_price, decimal.tp));
             im.qc_jl = ZhCalc.add(im.qc_jl, ZhCalc.mul(b.qc_jl, b.unit_price, decimal.tp));
@@ -661,7 +665,7 @@ const stageIm = (function () {
                 const pPos = gsPos.getLedgerPos(p.id);
                 if (pPos && pPos.length > 0) {
                     for (const pp of pPos) {
-                        if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) continue;
+                        if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty) && checkZero(pp.qc_minus_qty)) continue;
                         let im = nodeImData.find(function (d) {
                             return d.lid === node.id && d.pos_name === pp.name;
                         });
@@ -689,7 +693,7 @@ const stageIm = (function () {
                         }
                         addBwBillsGclBills(im, {
                             b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
+                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty,
                         });
 
                         if (pp.drawing_code && im.drawing_code instanceof Array)
@@ -707,11 +711,12 @@ const stageIm = (function () {
 
                     imDefault.contract_jl = ZhCalc.add(imDefault.contract_jl, p.contract_tp);
                     imDefault.qc_jl = ZhCalc.add(imDefault.qc_jl, p.qc_tp);
+                    imDefault.qc_minus_jl = 0;
                     imDefault.used = true;
 
                     addBwBillsGclBills(imDefault, {
                         b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                        jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
+                        jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty, qc_minus_jl: p.qc_qty,
                     });
                 }
             }
@@ -737,7 +742,7 @@ const stageIm = (function () {
         const posRange = gsPos.getLedgerPos(node.id);
         if (!posRange) { return }
         for (const p of posRange) {
-            if (!p.gather_qty || checkZero(p.gather_qty)) { continue; }
+            if (checkZero(p.contract_qty) && checkZero(p.qc_qty) && checkZero(p.qc_minus_qty)) { continue; }
             let lp = _.find(lx.pos, {name: p.name});
             if (!lp) {
                 lp = {name: p.name};
@@ -746,6 +751,7 @@ const stageIm = (function () {
             lp.jl = ZhCalc.add(lp.jl, p.gather_qty);
             lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty);
             lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty);
+            lp.qc_minus_jl = ZhCalc.add(lp.qc_minus_jl, p.qc_minus_qty);
         }
     }
     function generateZlLeafXmjData(node, im) {
@@ -766,6 +772,7 @@ const stageIm = (function () {
         lx.jl = ZhCalc.add(lx.jl, node.gather_qty);
         lx.contract_jl = ZhCalc.add(lx.contract_jl, node.contract_qty);
         lx.qc_jl = ZhCalc.add(lx.qc_jl, node.qc_qty);
+        lx.qc_minus_jl = ZhCalc.add(lx.qc_minus_jl, node.qc_minus_qty);
         generateZlPosData(node, lx);
     }
     function generateZlChangeData(node, im) {
@@ -809,7 +816,7 @@ const stageIm = (function () {
                 const peg = getPegNode(node);
                 im = {
                     lid: node.id, pid: '', code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field],
-                    jl: 0, contract_jl: 0, qc_jl: 0,
+                    jl: 0, contract_jl: 0, qc_jl: 0, qc_minus_jl: 0,
                     peg: peg ? getPegStr(peg.name) : '',
                     position: '',
                     lIndex: nodeIndex,
@@ -837,6 +844,7 @@ const stageIm = (function () {
             im.jl = ZhCalc.add(im.jl, p.gather_qty);
             im.contract_jl = ZhCalc.add(im.contract_jl, p.contract_qty);
             im.qc_jl = ZhCalc.add(im.qc_jl, p.qc_qty);
+            im.qc_minus_jl = ZhCalc.add(im.qc_minus_jl, p.qc_minus_qty);
         }
     }
 
@@ -851,10 +859,10 @@ const stageIm = (function () {
             if (pPos && pPos.length > 0) {
                 const nodeIndex = gsTree.getNodeIndex(node);
                 for (const pp of pPos) {
-                    if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) { continue }
+                    if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty) && checkZero(pp.qc_minus_qty)) { continue }
                     const im = {
                         lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field], pid: pp.id,
-                        jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,
+                        jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty,
                         //im_code: getNewImCode(),
                         bw: bw, jldy: pp.name,
                         peg: CheckPeg(pp.name) ? getPegStr(pp.name) : (peg ? getPegStr(peg.name) : ''),
@@ -867,7 +875,7 @@ const stageIm = (function () {
                         source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                         im_type: imType.bw.value,
                     };
-                    im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
+                    im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                     ImData.push(im);
                     for (const c of changes) {
                         if (c.lid === p.id && c.pid === pp.id && c.qty && c.qty !== 0) {
@@ -876,11 +884,11 @@ const stageIm = (function () {
                     }
                 }
             } else {
-                if (checkZero(p.gather_qty) && checkZero(p.gather_tp)) { continue }
+                if (checkZero(p.gather_qty) && checkZero(p.gather_tp) && checkZero(p.qc_minus_qty)) { continue }
 
                 const im = {
                     lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field], pid: '',
-                    jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty,
+                    jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty, qc_minus_jl: p.qc_minus_qty,
                     im_code: getNewImCode(),
                     bw: bw,
                     peg: peg ? getPegStr(peg.name) : '',
@@ -893,7 +901,7 @@ const stageIm = (function () {
                     source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                     im_type: imType.bw.value,
                 };
-                im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
+                im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                 ImData.push(im);
                 for (const c of changes) {
                     if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {

+ 20 - 6
app/service/change.js

@@ -1190,18 +1190,19 @@ module.exports = app => {
          * @param pos - 查询的部位
          * @return {Promise<*>} - 可用的变更令列表
          */
-        async getValidChanges(tender, stage, bills, pos) {
+        async getValidChanges(tender, stage, data, minusNoValue) {
+            const bills = data.bills, pos = data.pos;
             const self = this;
             const getFilterPart = function(field, value) {
                 return value
                     ? field + ' = ' + self.db.escape(value)
                     : self.db.format("(?? = null or ?? = '')", [field, field]);
             };
-            const filter = getFilterPart('cb.code', bills.b_code) +
+            let filter = getFilterPart('cb.code', bills.b_code) +
                 ' And ' + getFilterPart('cb.name', bills.name) +
                 ' And ' + getFilterPart('cb.unit', bills.unit) +
-                ' And cb.`unit_price` = ' + this.db.escape(bills.unit_price) +
-                (pos ? getFilterPart('cb.bwmx', pos.name) : '');
+                ' And cb.`unit_price` = ' + this.db.escape(bills.unit_price);
+            // if (data.pos) filter = filter + ' And ' + getFilterPart('cb.bwmx', pos.name);
             const sql =
                 'SELECT c.cid, c.code, c.name, c.w_code, c.p_code, c.peg, c.org_name, c.org_code, c.new_name, c.new_code,' +
                 '    c.content, c.basis, c.memo, c.type, c.class, c.quality, c.company, c.charge, ' +
@@ -1218,7 +1219,20 @@ module.exports = app => {
                 '  WHERE c.tid = ? And c.status = ? And c.valid And ' + filter +
                 '  ORDER BY c.in_time';
             const sqlParam = [tender.id, stage.order, tender.id, audit.flow.status.checked];
-            const changes = await this.db.query(sql, sqlParam);
+            let changes = await this.db.query(sql, sqlParam);
+            if (minusNoValue) {
+                if (data.minus) {
+                    changes = changes.filter(c => {
+                        c.bamount = c.b_amount ? parseFloat(c.b_amount) : 0;
+                        return c.bamount < 0;
+                    });
+                } else {
+                    changes = changes.filter(c => {
+                        c.bamount = c.b_amount ? parseFloat(c.b_amount) : 0;
+                        return c.bamount >= 0;
+                    });
+                }
+            }
             for (const c of changes) {
                 let sSql = 'SELECT * FROM ' + this.ctx.service.stageChange.tableName + ' WHERE sid = ? and cbid = ?';
                 const sSqlParam = [stage.id, c.cbid];
@@ -1227,7 +1241,7 @@ module.exports = app => {
                     sSqlParam.push(stage.curTimes, stage.curTimes, stage.curOrder);
                 }
                 const stageUsedData = await this.db.query(sSql, sSqlParam);
-                const filter = this.ctx.helper.filterLastestData(stageUsedData, ['pid', 'lid'], 'stimes', 'sorder');
+                const filter = this.ctx.helper.filterLastestData(stageUsedData, ['pid', 'lid', 'no_value'], 'stimes', 'sorder');
                 c.stage_used_amount = this.ctx.helper.sum(filter.map(x => { return x.qty }));
                 const aSql = 'SELECT ca.*, pa.name As u_name, pa.role As u_role ' +
                     '  FROM ?? As ca ' +

+ 6 - 6
app/service/change_audit_list.js

@@ -914,6 +914,9 @@ module.exports = app => {
                     total_price: sum.total_price,
                     deal_tp: sum.deal_tp,
                 });
+                // 清除修订及台账的maxLid缓存,防止树结构混乱
+                await this.ctx.service.reviseBills._removeCacheMaxLid(tid);
+                await this.ctx.service.ledger._removeCacheMaxLid(tid);
             }
         }
 
@@ -936,8 +939,8 @@ module.exports = app => {
                         l.ledger_pid, l.level, l.order, l.full_path, l.is_leaf, l.quantity, l.total_price,
                         l.unit_price, l.drawing_code, l.memo, l.dgn_qty1, l.dgn_qty2, l.deal_qty, l.deal_tp,
                         l.sgfh_qty, l.sgfh_tp, l.sjcl_qty, l.sjcl_tp, l.qtcl_qty, l.qtcl_tp, l.node_type, l.crid,
-                        l.tender_id, l.is_tp, l.sgfh_expr, l.sjcl_expr, l.qtcl_expr, l.check_calc, l.gxby_status,
-                        l.dagl_status, l.dagl_url, l.gxby_limit, l.dagl_limit, l.ex_memo1, l.ex_memo2, l.ex_memo3,
+                        l.tender_id, l.sgfh_expr, l.sjcl_expr, l.qtcl_expr, l.check_calc,
+                        l.ex_memo1, l.ex_memo2, l.ex_memo3,
                     ];
                     insertLedgerArr.push('(' + this.ctx.helper.getInArrStrSqlFilter(insertL) + ')');
                     await transaction.delete(this.ctx.service.changeLedger.tableName, { id: l.id });
@@ -948,9 +951,8 @@ module.exports = app => {
                     this.ctx.service.ledger.tableName +
                     '  (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                     '     quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                    '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                    '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                     '     sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                    '     gxby_status, dagl_status, dagl_url, gxby_limit,  dagl_limit,' +
                     '     ex_memo1, ex_memo2, ex_memo3) VALUES ' + insertLedgerArr.join(',') + ';';
                 await transaction.query(bSql, []);
             }
@@ -961,7 +963,6 @@ module.exports = app => {
                         p.id, p.tid, p.lid, p.name, p.drawing_code, p.quantity, p.add_stage, p.add_stage_order, p.add_times,
                         p.add_user, p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.crid, p.porder, p.position,
                         p.sgfh_expr, p.sjcl_expr, p.qtcl_expr, p.real_qty,
-                        p.gxby_status, p.dagl_status, p.dagl_url, p.gxby_limit, p.dagl_limit,
                         p.ex_memo1, p.ex_memo2, p.ex_memo3,
                     ];
                     insertPosArr.push('(' + this.ctx.helper.getInArrStrSqlFilter(insertp) + ')');
@@ -975,7 +976,6 @@ module.exports = app => {
                     '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                     '     sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position, ' +
                     '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                    '     gxby_status, dagl_status, dagl_url, gxby_limit,  dagl_limit,' +
                     '     ex_memo1, ex_memo2, ex_memo3)  VALUES ' + insertPosArr.join(',') + ';';
                 await transaction.query(pSql, []);
             }

+ 10 - 0
app/service/change_ledger.js

@@ -157,6 +157,16 @@ module.exports = app => {
             }
             return maxId;
         }
+        /**
+         * 移除最大节点id(修订时使用)
+         *
+         * @param {Number} mid - master id
+         * @return {Number}
+         * @private
+         */
+        async _removeCacheMaxLid(mid) {
+            return await this.cache.del(this.setting.keyPre + mid);
+        }
 
         /**
          * 根据 父节点id 和 节点排序order 获取数据

+ 1 - 12
app/service/ledger.js

@@ -686,6 +686,7 @@ module.exports = app => {
             const analysisExcel = new AnalysisExcel(this.ctx, this.setting);
             const tempData = await this.ctx.service.tenderNodeTemplate.getData(templateId, true);
             const cacheTree = analysisExcel.analysisData(excelData, tempData, { filterZeroGcl: filter });
+            cacheTree.calculateLeafWithPos();
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.delete(this.tableName, { tender_id: this.ctx.tender.id });
@@ -759,18 +760,6 @@ module.exports = app => {
                 throw (err.stack ? '导入工程量数据出错': err);
             }
         }
-
-        async loadDataFromOss(tid, url) {
-            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
-            const curData = await this.getAllDataByCondition({
-                columns: ['id', 'is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
-                where: { tender_id: tid }
-            });
-            this.ctx.helper.assignRelaData(data, [
-                { data: curData, fields: ['is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
-            ]);
-            return data;
-        }
     }
 
     return Ledger;

+ 37 - 0
app/service/ledger_extra.js

@@ -0,0 +1,37 @@
+'use strict';
+
+/**
+ * 部位明细
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+module.exports = app => {
+
+    class LedgerExtra extends app.BaseService {
+        /**
+         * 构造函数
+         *
+         * @param {Object} ctx - egg全局变量
+         * @return {void}
+         */
+        constructor(ctx) {
+            super(ctx);
+            this.depart = 10;
+            this.tableName = 'ledger_extra';
+        }
+
+        async getData(tid, columns) {
+            if (!columns || columns.length === 0) return [];
+
+            return await this.getAllDataByCondition({
+                where: { tid },
+                columns: ['id', ...columns],
+            });
+        }
+    }
+
+    return LedgerExtra;
+};

+ 5 - 0
app/service/ledger_history.js

@@ -71,6 +71,11 @@ module.exports = app => {
          * @private
          */
         async backupStageLedgerHistory(stage) {
+            const sbCount = await this.ctx.service.ledger.count({ tender_id: this.ctx.stage.tid });
+            const spCount = await this.ctx.service.pos.count({ tid: this.ctx.stage.tid });
+            const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
+            if (sbCount === ledgerHis.bills_count && spCount === ledgerHis.pos_count) return ledgerHis.id;
+
             const now = new Date();
             const timestamp = (now).getTime();
 

+ 6 - 6
app/service/ledger_revise.js

@@ -98,14 +98,14 @@ module.exports = app => {
             const sql = 'Insert Into ' + this.ctx.service.reviseBills.tableName +
                 '  (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '     quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3)' +
+                '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '      quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '      sgfh_expr, sjcl_expr, qtcl_expr, 0,' +
-                '      gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                '      ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' + this.ctx.service.ledger.tableName +
                 '  Where `tender_id` = ?';
             const sqlParam = [tid];
@@ -117,11 +117,11 @@ module.exports = app => {
                 '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, in_time, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3)' +
+                '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, in_time, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                '     ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' + this.ctx.service.pos.tableName +
                 '  Where `tid` = ?';
             const sqlParam = [tid];

+ 2 - 16
app/service/pos.js

@@ -29,7 +29,6 @@ module.exports = app => {
                 where: condition,
                 columns: column || ['id', 'tid', 'lid', 'name', 'quantity', 'position', 'drawing_code', 'sgfh_qty', 'sjcl_qty',
                     'qtcl_qty', 'in_time', 'porder', 'add_stage', 'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'real_qty',
-                    'dagl_status', 'dagl_url', 'gxby_status', 'gxby_url', 'gxby_limit', 'dagl_limit',
                     'ex_memo1', 'ex_memo2', 'ex_memo3'],
                 order: [['porder', 'ASC']],
             });
@@ -39,8 +38,7 @@ module.exports = app => {
             if (!condition.tid) throw '查询计量单元缺少必要信息';
             const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code,' +
                 '    sgfh_qty, sjcl_qty, qtcl_qty, porder, add_stage, add_times, add_user, add_stage_order,' +
-                '    sgfh_expr, sjcl_expr, qtcl_expr, real_qty, gxby_status, gxby_url, dagl_status, dagl_url,' +
-                '    gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                '    sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_memo1, ex_memo2, ex_memo3' +
                 '  FROM ' + this.departTableName(condition.tid) + this.ctx.helper.whereSql(condition);
             return await this.db.query(sql);
         }
@@ -49,7 +47,7 @@ module.exports = app => {
             if (ids instanceof Array && ids.length > 0) {
                 const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code,' +
                     '    sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user, sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                    '    dagl_status, dagl_url, gxby_status, gxby_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                    '    ex_memo1, ex_memo2, ex_memo3' +
                     '  FROM ' + this.departTableName(tid) +
                     '  WHERE id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ')';
                 return await this.db.query(sql, []);
@@ -503,18 +501,6 @@ module.exports = app => {
         async deletePosData(transaction, tid, lid) {
             await transaction.delete(this.tableName, {tid: tid, lid: lid});
         }
-
-        async loadDataFromOss(tid, url) {
-            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
-            const curData = await this.getAllDataByCondition({
-                columns: ['id', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
-                where: { tid: tid }
-            });
-            this.ctx.helper.assignRelaData(data, [
-                { data: curData, fields: ['gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
-            ]);
-            return data;
-        }
     }
 
     return Pos;

+ 37 - 0
app/service/pos_extra.js

@@ -0,0 +1,37 @@
+'use strict';
+
+/**
+ * 部位明细
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+module.exports = app => {
+
+    class LedgerExtra extends app.BaseService {
+        /**
+         * 构造函数
+         *
+         * @param {Object} ctx - egg全局变量
+         * @return {void}
+         */
+        constructor(ctx) {
+            super(ctx);
+            this.depart = 20;
+            this.tableName = 'pos_extra';
+        }
+
+        async getData(tid, columns) {
+            if (!columns || columns.length === 0) return [];
+
+            return await this.getAllDataByCondition({
+                where: { tid },
+                columns: ['id', ...columns],
+            });
+        }
+    }
+
+    return LedgerExtra;
+};

+ 4 - 2
app/service/project.js

@@ -11,6 +11,7 @@ const imType = require('../const/tender').imType;
 const defaultFunRela = {
     banOver: true,
     hintOver: true,
+    minusNoValue: false,
     imType: imType.zl.value,
     needGcl: false,
 };
@@ -55,7 +56,8 @@ module.exports = app => {
                     rule = {
                         imType: {type: 'enum', values: [imType.tz.value, imType.zl.value, imType.bb.value, imType.bw.value], required: true},
                         banOver: {type: 'bool', required: true,},
-                        hintOver: {type: 'bool', required: true,}
+                        hintOver: {type: 'bool', required: true,},
+                        minusNoValue: {type: 'bool', required: true,}
                     };
                     break;
                 default:
@@ -162,7 +164,7 @@ module.exports = app => {
             const result = await this.db.update(this.tableName, {
                 id: id, fun_rela: JSON.stringify({
                     banOver: data.banOver, hintOver: data.hintOver,
-                    imType: data.imType, needGcl: data.needGcl,
+                    imType: data.imType, needGcl: data.needGcl, minusNoValue: data.minusNoValue,
                 }),
             });
             return result.affectedRows === 1;

+ 4 - 26
app/service/report_memory.js

@@ -405,20 +405,9 @@ module.exports = app => {
                     preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                 }
                 this.ctx.helper.assignRelaData(billsData, [
-                    {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'},
-                    {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
+                    {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'}
                 ]);
-                if (this._checkFieldsExist(fields, billsFields.final1)) {
-                    const preMinusChange = await this.ctx.service.stageChangeFinal.getPreMinusChange(this.ctx.stage.tid, this.ctx.stage.order);
-                    const changeData = this.ctx.stage.readOnly
-                        ? await this.ctx.service.stageChange.getAuditorAllStageData(this.ctx.tender.id, this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder)
-                        : await this.ctx.service.stageChange.getLastestAllStageData(this.ctx.tender.id, this.ctx.stage.id);
-                    const minusChange = changeData.filter(x => { return x.minus });
-                    this.ctx.helper.assignSumRelaData(billsData, 'id', [
-                        {data: preMinusChange, fields: [{source: 'qty', target: 'pre_minus_qc_qty'}], relaField: 'lid'},
-                        {data: minusChange, fields: [{source: 'qty', target: 'minus_qc_qty'}], relaField: 'lid'},
-                    ]);
-                }
 
                 const billsTree = this._getNewBillsTree();
                 billsTree.loadDatas(billsData);
@@ -483,20 +472,9 @@ module.exports = app => {
                     prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                 }
                 this.ctx.helper.assignRelaData(posData, [
-                    {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'},
-                    {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
+                    {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'},
+                    {data: prePosStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid'}
                 ]);
-                if (this._checkFieldsExist(fields, posFields.final1)) {
-                    const preMinusChange = await this.ctx.service.stageChangeFinal.getPreMinusChange(this.ctx.stage.tid, this.ctx.stage.order);
-                    const changeData = this.ctx.stage.readOnly
-                        ? await this.ctx.service.stageChange.getAuditorAllStageData(this.ctx.tender.id, this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder)
-                        : await this.ctx.service.stageChange.getLastestAllStageData(this.ctx.tender.id, this.ctx.stage.id);
-                    const minusChange = changeData.filter(x => { return x.minus });
-                    this.ctx.helper.assignSumRelaData(posData, 'id', [
-                        {data: preMinusChange, fields: [{source: 'qty', target: 'pre_minus_qc_qty'}], relaField: 'pid'},
-                        {data: minusChange, fields: [{source: 'qty', target: 'minus_qc_qty'}], relaField: 'pid'},
-                    ]);
-                }
                 this.pos.loadDatas(posData);
                 this.pos.calculateAll();
 

+ 5 - 6
app/service/revise_audit.js

@@ -303,15 +303,13 @@ module.exports = app => {
                 this.ctx.service.ledger.tableName +
                 '  (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '     quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '      quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp, ' +
+                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, ' +
                 '      sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '      gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '      ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' +
                 this.ctx.service.reviseBills.tableName +
@@ -324,12 +322,10 @@ module.exports = app => {
                 '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position, ' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' +
                 this.ctx.service.revisePos.tableName +
@@ -427,6 +423,7 @@ module.exports = app => {
                         await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
                             status: SmsAliConst.status.success,
                         });
+
                         // 微信模板通知
                         // const wechatData2 = {
                         //     status: wxConst.status.success,
@@ -462,6 +459,8 @@ module.exports = app => {
                             total_price: sum.total_price,
                             deal_tp: sum.deal_tp,
                         });
+                        // 清除变更新增部位maxLid缓存,防止树结构混乱
+                        await this.ctx.service.changeLedger._removeCacheMaxLid(audit.tender_id);
                         // 短信通知-审批通过提醒功能
                         // 下一人
                         // const msg = '台账修订审批通过,请登录系统处理。';

+ 1 - 0
app/service/stage.js

@@ -545,6 +545,7 @@ module.exports = app => {
                 await transaction.delete(this.ctx.service.stageAudit.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageBills.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageChange.tableName, { sid: id });
+                await transaction.delete(this.ctx.service.stageChangeFinal.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageImportChange.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stagePos.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageDetail.tableName, { sid: id });

+ 2 - 14
app/service/stage_audit.js

@@ -470,20 +470,8 @@ module.exports = app => {
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), wxConst.template.stage, wechatData);
                 } else {
                     await this.ctx.service.tenderTag.saveTenderTag(this.ctx.tender.id, {stage_time: new Date()}, transaction);
-                    let his_id;
-                    if (this.ctx.tender.measureType === measureType.tz.value) {
-                        const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
-                        his_id = ledgerHis.id;
-                    } else {
-                        const sbCount = await this.ctx.service.ledger.count({ tender_id: this.ctx.stage.tid });
-                        const spCount = await this.ctx.service.pos.count({ tid: this.ctx.stage.tid });
-                        const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
-                        if (sbCount > ledgerHis.bills_count || spCount > ledgerHis.pos_count) {
-                            his_id = await this.ctx.service.ledgerHistory.backupStageLedgerHistory(this.ctx.stage);
-                        } else {
-                            his_id = ledgerHis.id;
-                        }
-                    }
+                    const his_id = await this.ctx.service.ledgerHistory.backupStageLedgerHistory(this.ctx.stage);
+
                     // 本期结束
                     // 生成截止本期数据 final数据
                     await this.ctx.service.stageBillsFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage);

+ 15 - 7
app/service/stage_bills.js

@@ -182,6 +182,7 @@ module.exports = app => {
                 d.contract_tp = orgData.contract_tp;
                 d.qc_qty = orgData.qc_qty;
                 d.qc_tp = orgData.qc_tp;
+                d.qc_minus_qty = orgData.qc_minus_qty;
                 d.postil = orgData.postil;
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
@@ -195,6 +196,7 @@ module.exports = app => {
                 d.qc_qty = this.round(insertData.qc_qty, precision.value);
                 d.qc_tp = this.ctx.helper.mul(d.qc_qty, ledgerData.unit_price, info.decimal.tp);
             }
+            if (insertData.qc_minus_qty !== undefined) d.qc_minus_qty = this.round(insertData.qc_minus_qty, precision.value);
             if (insertData.postil) {
                 d.postil = insertData.postil;
             }
@@ -215,7 +217,7 @@ module.exports = app => {
             try {
                 for (const d of datas) {
                     const stageBills = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, d.lid);
-                    const ledgerBills = await this.ctx.service.ledger.getDataById(d.lid);
+                    const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(d.lid);
                     if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
                         await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
                     } else {
@@ -268,7 +270,7 @@ module.exports = app => {
         async calc(tid, sid, lid, transaction) {
             const info = this.ctx.tender.info;
             const stageBills = await this.getLastestStageData2(tid, sid, lid);
-            const ledgerBills = await this.ctx.service.ledger.getDataById(lid);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(lid);
             if (!ledgerBills) {
                 throw '提交数据错误';
             }
@@ -286,7 +288,7 @@ module.exports = app => {
                 posGather.qc_tp = this.ctx.helper.mul(posGather.qc_qty, ledgerBills.unit_price, info.decimal.tp);
             }
             if (stageBills) {
-                if (stageBills.contract_qty === posGather.contract_qty && stageBills.qc_qty === posGather.qc_qty) {
+                if (stageBills.contract_qty === posGather.contract_qty && stageBills.qc_qty === posGather.qc_qty && stageBills.qc_minus_qty === posGather.qc_minus_qty) {
                     return;
                 }
                 if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
@@ -303,14 +305,20 @@ module.exports = app => {
 
         async updateStageBillsCalcType(data) {
             const stageBills = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, data.id);
+            const le = await this.ctx.service.ledgerExtra.getDataById(data.id);
             const updateData = { contract_qty: null, contract_tp: null };
 
             const transaction = await this.db.beginTransaction();
             try {
-                await transaction.update(this.ctx.service.ledger.tableName, data);
+                if (le) {
+                    await transaction.update(this.ctx.service.ledgerExtra.tableName, data);
+                } else {
+                    data.tid = this.ctx.tender.id;
+                    await transaction.insert(this.ctx.service.ledgerExtra.tableName, data);
+                }
                 if (stageBills) {
                     if (stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
-                        const ledgerBills = await this.ctx.service.ledger.getDataById(data.id);
+                        const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(data.id);
                         await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
                     } else {
                         updateData.id = stageBills.id;
@@ -323,7 +331,7 @@ module.exports = app => {
                 throw err;
             }
 
-            const bills = await this.ctx.service.ledger.getDataById(data.id);
+            const bills = await this.ctx.service.ledger.getCompleteDataById(data.id);
             const curStageData = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, [data.id]);
             return { bills: [bills], curStageData };
         }
@@ -449,7 +457,7 @@ module.exports = app => {
             const conn = await this.db.beginTransaction();
             try {
                 const maxId = await this.ctx.service.ledger._getMaxLid(this.ctx.tender.id);
-                const select = await this.ctx.service.ledger.getDataById(lid);
+                const select = await this.ctx.service.ledger.getCompleteDataById(lid);
                 const sumLoad = new SumLoad(this.ctx);
                 const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders, null, cover);
                 const result = loadTree.getUpdateData();

+ 6 - 15
app/service/stage_bills_final.js

@@ -77,7 +77,6 @@ module.exports = app => {
             }
             const cur = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
             const pre = await this.getFinalData(tender, stage.order - 1);
-            const minusChange = await this.ctx.service.stageChange.getStageMinusChange(stage);
             if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return;
             for (const c of cur) {
                 delete c.id;
@@ -94,22 +93,13 @@ module.exports = app => {
                     c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
                     c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
                     c.qc_tp = this.ctx.helper.add(c.qc_tp, p.qc_tp);
-                    if (p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
-                        || !this.ctx.helper.checkZero(c.contract_tp)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.lid === c.lid && x.qty < 0 });
-                        c.used = !!mc;
-                    }
+                    c.qc_minus_qty = this.ctx.helper.add(c.qc_minus_qty, p.qc_minus_qty);
+                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
+                        || !this.ctx.helper.checkZero(c.contract_tp) || ! this.ctx.helper.checkZero(c.qc_minus_qty);
                     pre.splice(pre.indexOf(p), 1);
                 } else {
-                    if (!this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
-                        || !this.ctx.helper.checkZero(c.contract_tp)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.lid === c.lid && x.qty < 0 });
-                        c.used = !!mc;
-                    }
+                    c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
+                        || !this.ctx.helper.checkZero(c.contract_tp) || ! this.ctx.helper.checkZero(c.qc_minus_qty);
                 }
             }
 
@@ -118,6 +108,7 @@ module.exports = app => {
                 p.sid = stage.id;
                 p.sorder = stage.order;
             }
+            await transaction.delete(this.tableName, { tid: tender.id, sid: stage.id });
             await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre);
         }
 

+ 44 - 39
app/service/stage_change.js

@@ -36,22 +36,24 @@ module.exports = app => {
          * @param {Number} pid - 部位明细id
          * @return {Promise<*>}
          */
-        async getLastestStageData(tid, sid, lid, pid) {
+        async getLastestStageData(tid, sid, lid, pid, noValue) {
+            const filter = noValue !== undefined ? ' And no_value = ?' : '';
             const sql = 'SELECT c.*,' +
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
-                '      WHERE tid = ? And sid = ? And lid = ? And pid = ?' +
-                '      GROUP By `lid`, `pid`, `cid`, `cbid`' +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
+                '      WHERE tid = ? And sid = ? And lid = ? And pid = ?' + filter +
+                '      GROUP By `lid`, `pid`, `cid`, `cbid`, `no_value`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
                 '  ON c.cbid = ocb.id' +
                 '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, lid, pid ? pid : -1];
+            if (noValue !== undefined) sqlParam.push(noValue);
             return await this.db.query(sql, sqlParam);
         }
 
@@ -65,22 +67,24 @@ module.exports = app => {
          * @param {Number} pid - 部位明细id
          * @return {Promise<*>}
          */
-        async getAuditorStageData(tid, sid, times, order, lid, pid) {
+        async getAuditorStageData(tid, sid, times, order, lid, pid, noValue) {
+            const filter = noValue !== undefined ? ' And no_value = ?' : '';
             const sql = 'SELECT c.*,' +
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
-                '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
+                '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' + filter +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
                 '  ON c.cbid = ocb.id' +
                 '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, times, times, order, lid, pid ? pid : -1];
+            if (noValue !== undefined) sqlParam.push(noValue);
             return await this.db.query(sql, sqlParam);
         }
 
@@ -89,11 +93,11 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ?' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
@@ -108,11 +112,11 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
@@ -129,24 +133,24 @@ module.exports = app => {
          * @param {Array} changes - 调用的变更令
          * @return {Promise<void>}
          */
-        async billsChange(bills, changes) {
+        async billsChange(bills, noValue, changes) {
             const self = this;
-            function getNewChange(cid, cbid, times, order, qty, minus) {
+            function getNewChange(cid, cbid, times, order, qty, minus, no_value) {
                 return {
                     tid: self.ctx.tender.id, sid: self.ctx.stage.id,
                     lid: bills.id, pid: -1,
                     cid, cbid,
                     stimes: times, sorder: order,
-                    qty, minus
+                    qty, minus, no_value,
                 };
             }
-            const ledgerBills = await this.ctx.service.ledger.getDataById(bills.id);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(bills.id);
             if (!ledgerBills || ledgerBills.tender_id !== this.ctx.tender.id) {
                 throw '提交数据错误';
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerBills.unit);
             // 获取原变更令
-            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, bills.id, -1);
+            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, bills.id, -1, noValue);
             // 获取更新数据
             const updateChanges = [],
                 newChanges = [];
@@ -155,7 +159,7 @@ module.exports = app => {
                 const nc = this._.find(changes, { cid: oc.cid, cbid: oc.cbid });
                 if (!nc || nc.qty !== oc.qty) {
                     const qty = nc ? this.round(nc.qty, precision.value) : null;
-                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus);
+                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus, noValue);
                     billsQty = this.ctx.helper.add(billsQty, change.qty);
                     if (oc.stimes === this.ctx.stage.curTimes && oc.sorder === this.ctx.stage.curOrder) {
                         change.id = oc.id;
@@ -170,7 +174,7 @@ module.exports = app => {
             for (const c of changes) {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
-                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus);
+                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus, noValue);
                     billsQty = this.ctx.helper.add(billsQty, change.qty);
                     newChanges.push(change);
                 }
@@ -185,7 +189,8 @@ module.exports = app => {
                     await transaction.update(this.tableName, c);
                 }
                 const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, bills.id);
-                await this.ctx.service.stageBills.updateStageBillsQty(transaction, ledgerBills, stageBills, { qc_qty: billsQty });
+                const sbUpdate = noValue ? {qc_minus_qty: billsQty} : {qc_qty: billsQty};
+                await this.ctx.service.stageBills.updateStageBillsQty(transaction, ledgerBills, stageBills, sbUpdate);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -202,24 +207,24 @@ module.exports = app => {
          * @param {Array} changes - 调用的变更令
          * @return {Promise<{}>}
          */
-        async posChange(pos, changes) {
+        async posChange(pos, noValue, changes) {
             const self = this;
-            function getNewChange(cid, cbid, times, order, qty, minus) {
+            function getNewChange(cid, cbid, times, order, qty, minus, no_value) {
                 return {
                     tid: self.ctx.tender.id, sid: self.ctx.stage.id,
                     lid: pos.lid, pid: pos.id,
                     cid, cbid,
                     stimes: times, sorder: order,
-                    qty, minus
+                    qty, minus, no_value,
                 };
             }
-            const ledgerBills = await this.ctx.service.ledger.getDataById(pos.lid);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(pos.lid);
             if (!ledgerBills || ledgerBills.tender_id !== this.ctx.tender.id) {
                 throw '提交数据错误';
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerBills.unit);
             // 获取原变更令
-            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.lid, pos.id);
+            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.lid, pos.id, noValue);
             const updateChanges = [],
                 newChanges = [];
             let posQty = 0;
@@ -227,7 +232,7 @@ module.exports = app => {
                 const nc = this._.find(changes, { cid: oc.cid, cbid: oc.cbid });
                 if (!nc || nc.qty !== oc.qty) {
                     const qty = nc ? this.round(nc.qty, precision.value) : null;
-                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus);
+                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus, noValue);
                     posQty = this.ctx.helper.add(posQty, change.qty);
                     if (oc.stimes === this.ctx.stage.curTimes && oc.sorder === this.ctx.stage.curOrder) {
                         change.id = oc.id;
@@ -242,7 +247,7 @@ module.exports = app => {
             for (const c of changes) {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
-                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus);
+                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus, noValue);
                     posQty = this.ctx.helper.add(posQty, change.qty);
                     newChanges.push(change);
                 }
@@ -252,7 +257,7 @@ module.exports = app => {
             try {
                 if (newChanges.length > 0) await transaction.insert(this.tableName, newChanges);
                 if (updateChanges.length > 0) await transaction.updateRows(this.tableName, updateChanges);
-                await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty);
+                await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty, noValue);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -292,7 +297,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [tid, cid, this.ctx.stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ?';
                 const curAll = await this.db.query(sql, [this.ctx.stage.id]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }
@@ -317,7 +322,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [tid, cid, stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ? and cid = ?';
                 const curAll = await this.db.query(sql, [stage.id, cid]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }
@@ -338,7 +343,7 @@ module.exports = app => {
                         '  INNER JOIN ( ' +
                         '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid`, `sid` From ' + this.tableName +
                         '      WHERE sid = ? And cid = ?' +
-                        '      GROUP By `lid`, `pid`, `cbid`' +
+                        '      GROUP By `lid`, `pid`, `cbid`, `no_value`' +
                         '  ) As m ' +
                         '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid And c.sid = m.sid' +
                         '  LEFT JOIN ' + this.ctx.service.ledger.tableName + ' As l ON c.lid = l.id' +
@@ -355,13 +360,13 @@ module.exports = app => {
         async getStageUsedChangeId(sid) {
             const sql = 'SELECT lid, pid, cid, cbid, qty, stimes, sorder FROM ' + this.tableName + ' WHERE sid = ?';
             const curAll = await this.db.query(sql, [sid]);
-            const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+            const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
             return this._.map(this._.filter(cur, 'qty'), 'cid');
         }
 
         async getFinalStageData(tid, sid) {
             const data = await this.getAllDataByCondition({ where: { tid, sid } });
-            return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+            return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
         }
 
         async getSumLoadFinalData(sid) {
@@ -370,7 +375,7 @@ module.exports = app => {
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Where cf.sid = ?';
             const result = await this.db.query(sql, [sid]);
-            return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
+            return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
         }
 
         async _getTender(stage) {
@@ -425,7 +430,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [stage.tid, stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ? AND (stimes * 100 + sorder) <= (? * 100 + ?)';
                 const curAll = await this.db.query(sql, [stage.id, stage.curTimes, stage.curOrder]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }

+ 2 - 13
app/service/stage_change_final.js

@@ -64,9 +64,10 @@ module.exports = app => {
                 data.push({
                     tid: c.tid, sid: c.sid, sorder: stage.order,
                     lid: c.lid, pid: c.pid, cid: c.cid, cbid: c.cbid,
-                    qty: c.qty, minus: c.minus,
+                    qty: c.qty, minus: c.minus, no_value: c.no_value,
                 });
             }
+            await transaction.delete(this.tableName, { tid: tender.id, sid: stage.id });
             if (data.length > 0) await transaction.insert(this.tableName, data);
         }
 
@@ -101,18 +102,6 @@ module.exports = app => {
             const usedQty = await this.db.queryOne('Select SUM(qty) as qty FROM ' + this.tableName + ' WHERE cbid = ?', [cbid]);
             return usedQty ? this.ctx.helper.sub(qty, usedQty.qty) : qty;
         }
-
-        async getPreMinusChange(tid, sorder) {
-            const sql = 'SELECT lid, pid, SUM(qty) as qty FROM ' + this.tableName + ' WHERE tid = ? and sorder < ? and minus GROUP BY lid, pid';
-            const data = await this.db.query(sql, [tid, sorder]);
-            return data;
-        }
-
-        async getMinusChange(tid) {
-            const sql = 'SELECT lid, pid, SUM(qty) as qty FROM ' + this.tableName + ' WHERE tid = ? GROUP BY lid, pid';
-            const data = await this.db.query(sql, [tid]);
-            return data;
-        }
     }
 
     return StageChangeFinal;

+ 8 - 7
app/service/stage_pos.js

@@ -108,7 +108,7 @@ module.exports = app => {
         }
         async getLastestStageData2(tid, sid, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, postil, `times`, `order`, `contract_expr`' +
+            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, qc_minus_qty, postil, `times`, `order`, `contract_expr`' +
                 '  FROM ' + this.departTableName(tid) +
                 '  WHERE tid = ? And sid = ? ' + filterSql;
             const sqlParam = [tid, sid];
@@ -117,7 +117,7 @@ module.exports = app => {
         }
         async getAuditorStageData2(tid, sid, times, order, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, postil, `times`, `order`, `contract_expr`' +
+            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, qc_minus_qty, postil, `times`, `order`, `contract_expr`' +
                 '  FROM ' + this.departTableName(tid) +
                 '  WHERE tid = ? And sid = ? And (`times` < ? OR (`times` = ? AND `order` <= ?)) ' + filterSql;
             const sqlParam = [tid, sid, times, times, order];
@@ -545,7 +545,7 @@ module.exports = app => {
             }
         }
 
-        async updateChangeQuantity(transaction, pos, qty) {
+        async updateChangeQuantity(transaction, pos, qty, noValue) {
             let orgPos = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, {pid: pos.id});
             if (orgPos.length > 1) {
                 throw '数据错误';
@@ -553,7 +553,7 @@ module.exports = app => {
                 orgPos = orgPos[0];
             }
             if (orgPos && orgPos.times === this.ctx.stage.curTimes && orgPos.order === this.ctx.stage.curOrder) {
-                await transaction.update(this.tableName, {id: orgPos.id, qc_qty: qty});
+                await transaction.update(this.tableName, noValue ? {id: orgPos.id, qc_minus_qty: qty} : {id: orgPos.id, qc_qty: qty});
             } else {
                 await transaction.insert(this.tableName, {
                     tid: this.ctx.tender.id,
@@ -564,7 +564,8 @@ module.exports = app => {
                     times: this.ctx.stage.curTimes,
                     order: this.ctx.stage.curOrder,
                     contract_qty: orgPos ? orgPos.contract_qty : 0,
-                    qc_qty: qty,
+                    qc_qty: !noValue ? qty : (orgPos ? orgPos.qc_qty : 0),
+                    qc_minus_qty: noValue ? qty : (orgPos ? orgPos.qc_minus_qty : 0),
                 });
             }
             await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, pos.lid, transaction);
@@ -579,8 +580,8 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getPosGather(tid, sid, lid, transaction) {
-            const calcQtySql = 'SELECT SUM(`contract_qty`) As `contract_qty`, SUM(`qc_qty`) As `qc_qty` FROM (' +
-                '  SELECT `contract_qty`, `qc_qty` FROM ' + this.ctx.service.stagePos.tableName + ' As Pos ' +
+            const calcQtySql = 'SELECT SUM(`contract_qty`) As `contract_qty`, SUM(`qc_qty`) As `qc_qty`, SUM(`qc_minus_qty`) AS `qc_minus_qty` FROM (' +
+                '  SELECT `contract_qty`, `qc_qty`, `qc_minus_qty` FROM ' + this.ctx.service.stagePos.tableName + ' As Pos ' +
                 '    INNER JOIN (' +
                 '      SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid` ' +
                 '        FROM ' + this.ctx.service.stagePos.tableName +

+ 4 - 14
app/service/stage_pos_final.js

@@ -59,7 +59,6 @@ module.exports = app => {
             }
             const cur = await this.ctx.service.stagePos.getLastestStageData2(tender.id, stage.id);
             const pre = stage.order > 1 ? await this.getFinalData(tender, stage.order - 1) : [];
-            const minusChange = await this.ctx.service.stageChange.getStageMinusChange(stage);
             if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return;
             for (const c of cur) {
                 delete c.id;
@@ -74,28 +73,19 @@ module.exports = app => {
                 if (p) {
                     c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
                     c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
-                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                    c.qc_minus_qty = this.ctx.helper.add(c.qc_minus_qty, p.qc_minus_qty);
+                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty) || !this.ctx.helper.checkZero(c.qc_minus_qty);
                     pre.splice(pre.indexOf(p), 1);
                 } else {
-                    if (!this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.pid === c.pid && x.qty < 0});
-                        c.used = !!mc;
-                    }
+                    c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty) || !this.ctx.helper.checkZero(c.qc_minus_qty);
                 }
             }
             for (const p of pre) {
                 if (p.id !== undefined) delete p.id;
                 p.sid = stage.id;
                 p.sorder = stage.order;
-                if (p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty)) {
-                    p.used = true;
-                } else {
-                    const mc = minusChange.find(x => { return x.pid === p.pid && x.qty < 0});
-                    p.used = !!mc;
-                }
             }
+            await transaction.delete(this.tableName, { tid: tender.id, sid: stage.id });
             await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre);
         }
 

+ 12 - 8
app/service/stage_stash.js

@@ -72,9 +72,9 @@ class loadStageExcelTree {
                 let ssp = sourceStagePos.find(x => { return x.pid === sp.id; });
                 sourceStagePos.splice(sourceStagePos.indexOf(ssp), 1);
                 if (ssp) {
-                    this.updatePos.push({ id: ssp.id, contract_qty: p.contract_qty });
+                    this.updatePos.push({ id: ssp.id, contract_qty: p.contract_qty, postil: p.postil || ssp.postil || '' });
                 } else {
-                    this.insertPos.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, pid:sp.id, contract_qty: p.contract_qty });
+                    this.insertPos.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, pid:sp.id, contract_qty: p.contract_qty, postil: p.postil || ssp.postil || '' });
                 }
             }
             for (const ssp of sourceStagePos) {
@@ -82,9 +82,9 @@ class loadStageExcelTree {
             }
             const contract_tp = this.ctx.helper.mul(contract_qty, source.unit_price, this.decimal.tp);
             if (curStageBills) {
-                this.updateBills.push({ id: curStageBills.id, contract_qty, contract_tp });
+                this.updateBills.push({ id: curStageBills.id, contract_qty, contract_tp, postil: node.postil || source.postil || '' });
             } else {
-                if (contract_qty) this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty, contract_tp });
+                if (contract_qty) this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty, contract_tp, postil: node.postil || source.postil || '' });
             }
         } else {
             if (!node.contract_qty && !node.contract_tp) return;
@@ -94,9 +94,9 @@ class loadStageExcelTree {
                 : this.ctx.helper.round(contract_tp, this.decimal.tp);
 
             if (curStageBills) {
-                this.updateBills.push({ id: curStageBills.id, contract_qty: contract_qty, contract_tp: contract_tp });
+                this.updateBills.push({ id: curStageBills.id, contract_qty: contract_qty, contract_tp: contract_tp, postil: node.postil || source.postil || '' });
             } else {
-                this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty: contract_qty, contract_tp: contract_tp });
+                this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty: contract_qty, contract_tp: contract_tp, postil: node.postil || source.postil || '' });
             }
         }
     }
@@ -325,12 +325,16 @@ module.exports = app => {
                     columns: ['id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf', 'code', 'b_code', 'name', 'unit', 'unit_price', 'is_tp'],
                     where: { tender_id: stage.tid},
                 });
+                const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
+                this.ctx.helper.assignRelaData(ledgerData, [
+                    { data: extraData, fields: ['is_import'], prefix: '', relaId: 'id' },
+                ]);
                 const posData = await this.ctx.service.pos.getAllDataByCondition({
                     columns: ['id', 'lid', 'name', 'porder'],
                     where: { tid: stage.tid },
                 });
-                const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id }});
-                const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id }});
+                const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
+                const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
                 const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
 
                 const loadModal = new loadStageExcelTree(this.ctx);

+ 14 - 0
app/view/setting/fun.ejs

@@ -29,6 +29,19 @@
                         </div>
                         <div class="card mb-3">
                             <div class="card-body">
+                                <h5 class="card-title">负变更</h5>
+                                <div class="form-group mb-4">
+                                    <div>
+                                        <div class="form-check form-check-inline">
+                                            <input class="form-check-input" type="checkbox" id="minusNoValue" name="minusNoValue" <% if (funRela.minusNoValue) { %>checked<% } %> onchange="updateSetting();">
+                                            <label class="form-check-label" for="minusNoValue">计量不计价</label>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="card mb-3">
+                            <div class="card-body">
                                 <h5 class="card-title">中间计量模式设置</h5>
                                 <div class="form-group mb-4">
                                     <div>
@@ -135,6 +148,7 @@
             imType: parseInt($('[name=im_type]:checked').val()),
             banOver: $('[name=ban_over]')[0].checked,
             hintOver: $('#hint_over')[0].checked,
+            minusNoValue: $('[name=minusNoValue]')[0].checked,
             needGcl: $('#need_gcl')[0].checked,
             openChangeProject: $('#openChangeProject')[0].checked,
             openChangeApply: $('#openChangeApply')[0].checked,

+ 1 - 0
app/view/stage/gather.ejs

@@ -104,4 +104,5 @@
     const chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
     const hintOver = <%- hintOver %>;
+    const tenderDecimal = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.tender.info.decimal)) %>'));
 </script>

+ 11 - 0
app/view/stage/index.ejs

@@ -151,6 +151,9 @@
                                 <tbody>
                                 <tr><th width="120" name="type-title-contract">本期合同计量数量</th><td id="show-contract-jl"></td></tr>
                                 <tr><th name="type-title-qc">本期变更计量数量</th><td id="show-qc-jl"></td></tr>
+                                <% if (minusNoValue) { %>
+                                <tr><th name="type-title-qc-minus">本期不计价变更数量</th><td id="show-qc-minus-jl"></td></tr>
+                                <% } %>
                                 <tr><th>变更令号</th><td id="show-bgl-code"></td></tr>
                                 <tr><th>变更图号</th><td id="show-bgl-drawing-code"></td></tr>
                                 <tr><th>部位</th><td id="show-bw-name"></td></tr>
@@ -180,6 +183,14 @@
                                     </div>
                                     <input type="text" class="form-control" value="" id="qc-jl" readonly="">
                                 </div>
+                                <% if (minusNoValue) { %>
+                                <div class="input-group input-group-sm mb-2">
+                                    <div class="input-group-prepend">
+                                        <span class="input-group-text" name="type-title-qc-minus">本期不计价变更数量</span>
+                                    </div>
+                                    <input type="text" class="form-control" value="" id="qc-minus-jl" readonly="">
+                                </div>
+                                <% } %>
                                 <div class="input-group input-group-sm mb-2">
                                     <div class="input-group-prepend">
                                         <span class="input-group-text">变更令号</span>

+ 10 - 0
app/view/tender/detail_modal.ejs

@@ -1806,6 +1806,12 @@
                 </div>
                 <div class="form-group">
                     <div class="custom-control custom-checkbox mb-2">
+                        <input type="checkbox" class="custom-control-input" id="sc_minusNoValue" checked="">
+                        <label class="custom-control-label" for="sc_minusNoValue">计量台账-负变更-计量不计价</label>
+                    </div>
+                </div>
+                <div class="form-group">
+                    <div class="custom-control custom-checkbox mb-2">
                         <input type="checkbox" class="custom-control-input" id="sr_show" checked="">
                         <label class="custom-control-label" for="sr_show">关联台账</label>
                     </div>
@@ -1856,6 +1862,7 @@
 
     const loadFunRelaProperty = function () {
         $('#sl_ignoreParent')[0].checked = property.fun_rela.sum_load.ignoreParent;
+        $('#sc_minusNoValue')[0].checked = property.fun_rela.stage_change.minusNoValue;
         $('#sr_show')[0].checked = property.fun_rela.stage_rela.show;
         $('#hint_over')[0].checked = property.fun_rela.hintOver;
     };
@@ -1870,6 +1877,9 @@
                 sum_load: {
                     ignoreParent: $('#sl_ignoreParent')[0].checked,
                 },
+                stage_change: {
+                    minusNoValue: $('#sc_minusNoValue')[0].checked,
+                },
                 stage_rela: {
                     show: $('#sr_show')[0].checked,
                 }

+ 70 - 0
db_script/minus_no_value.js

@@ -0,0 +1,70 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const mysql = require('mysql');
+const config = process.argv.splice(2)[0];
+if (['local', 'uat', 'default'].indexOf(config) < 0) throw `参数错误: ${config}`;
+const options = require(`../config/config.${config}`)({ baseDir: __dirname + '/app', root: __dirname, name: 'calc' });
+
+const pool = mysql.createPool(options.mysql.client);
+
+const querySql = async function(sql, sqlParam) {
+    return new Promise(function(resolve, reject) {
+        pool.getConnection(function(err, conn) {
+            if (err) {
+                if (err) console.log(err);
+                reject(err);
+            } else {
+                conn.query(sql, sqlParam, function(err, rows, fields) {
+                    if (err) console.log(err);
+                    // 释放连接
+                    conn.release();
+                    // 传递Promise回调对象
+                    resolve(rows);
+                });
+            }
+        });
+    });
+};
+
+const doCompleteProject = async function(p) {
+    const fun_rela = p.fun_rela ? JSON.parse(p.fun_rela) : {};
+    fun_rela.minusNoValue = false;
+    await querySql('Update zh_project Set fun_rela = ? Where id = ?', [JSON.stringify(fun_rela), p.id]);
+};
+const doCompleteTender = async function(t) {
+    const info = await querySql('Select * From zh_tender_info Where tid = ?');
+    if (info.length > 0) {
+        const fun_rela = t.fun_rela ? JSON.parse(t.fun_rela) : {};
+        fun_rela.stage_chagne = { minusNoValue: false };
+        await querySql('Update zh_tender_info Set fun_rela = ? Where tid = ?', [JSON.stringify(fun_rela), t.id]);
+    } else {
+        const fun_rela = { stage_change: { minusNoValue: false } };
+        await querySql('Insert Into zh_tender_info {pid, tid, fun_rela} Values(?, ?, ?)', [t.project_id, t.id, JSON.stringify(fun_rela)]);
+    }
+};
+
+const doComplete = async function() {
+    try {
+        const project = await querySql('Select * From zh_project');
+        for (const p of project) {
+            await doCompleteProject(p);
+        }
+        const tenders = await querySql('Select * From zh_tender');
+        for (const t of tenders) {
+            await doCompleteTender(t);
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    pool.end();
+};
+doComplete();
+

+ 27 - 0
publish.md

@@ -0,0 +1,27 @@
+# 发布相关
+记录发布流程,执行脚本写完后,需更新到
+
+## 默认操作
+1. 合并代码至uat/master
+2. 登录阿里云,在相关数据库中,执行update.sql和index.sql
+3. jenkins,发布脚本,执行升级脚本(按需)
+4. 登录jenkins,发布代码
+
+##特殊操作
+如果没有特殊说明,则在第默认操作的第3步前,执行相关脚本,如果有特殊要求,需特别说明
+
+### 2022-05-31 ~ ...
+3.1. ledger_his_count: 更新ledger_history表中新增的bills_count和pos_count两个字段数据
+3.2. minus_no_value: 更新project.fun_rela.minusNoValue=false和tender_info.fun_rela.stage_change.minusNoValue=false
+
+### uat
+```bash
+$ node ledger_his_count uat
+$ node minus_no_value uat
+```
+
+### prod
+```bash
+$ node ledger_his_count default
+$ node minus_no_value default
+```

+ 731 - 0
sql/update.sql

@@ -5,3 +5,734 @@ ADD COLUMN `pos_count`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计量单
 UPDATE `zh_tender` SET `had_map`=3 WHERE `had_map`=1;
 
 ALTER TABLE `zh_tender` ADD `map_pic` VARCHAR(255) NULL DEFAULT NULL COMMENT '静态图片地址' AFTER `had_map`;
+
+CREATE TABLE `zh_ledger_extra_0` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_1` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_2` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_3` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_4` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_5` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_6` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_7` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_8` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_ledger_extra_9` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`is_tp`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+
+
+CREATE TABLE `zh_pos_extra_0` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_1` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_2` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_3` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_4` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_5` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_6` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_7` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_8` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_9` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_10` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_11` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_12` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_13` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_14` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_15` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_16` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_17` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_18` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+CREATE TABLE `zh_pos_extra_19` (
+`id`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'uuid' ,
+`tid`  int(11) UNSIGNED NOT NULL COMMENT '标段id' ,
+`gxby_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '工序报验-状态' ,
+`gxby_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_status`  tinyint(4) NULL DEFAULT '-1' COMMENT '档案管理-状态' ,
+`gxby_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '工序报验-查看链接' ,
+`dagl_limit`  int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限,0不受限,1受限' ,
+`dagl_url`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接' ,
+PRIMARY KEY (`id`)
+);
+
+
+INSERT INTO zh_ledger_extra_0 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_0
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_1 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_1
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_2 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_2
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_3 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_3
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_4 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_4
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_5 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_5
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_6 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_6
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_7 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_7
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_8 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_8
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_ledger_extra_9 ( id, tid, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tender_id, is_tp, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_ledger_9
+  WHERE is_tp <> 0 or gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+
+INSERT INTO zh_pos_extra_0 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_0
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_1 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_1
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_2 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_2
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_3 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_3
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_4 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_4
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_5 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_5
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_6 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_6
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_7 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_7
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_8 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_8
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_9 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_9
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_10 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_10
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_11 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_11
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_12 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_12
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_13 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_13
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_14 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_14
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_15 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_15
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_16 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_16
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_17 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_17
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_18 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_18
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+INSERT INTO zh_pos_extra_19 ( id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url )
+  SELECT id, tid, gxby_status, gxby_limit, gxby_url, dagl_status, dagl_limit, dagl_url
+  FROM zh_pos_19
+  WHERE gxby_status <> -1 or gxby_limit <> 0 or gxby_url <> '' or dagl_status <> -1 or dagl_limit <> 0 or dagl_url <> '';
+
+ALTER TABLE `zh_stage_bills_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_bills_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_pos_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+
+ALTER TABLE `zh_stage_pos_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+ALTER TABLE `zh_stage_change`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_change_final`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_detail`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计量不计价' AFTER `unit_price`;
+
+
+ALTER TABLE `zh_stage_bills_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_bills_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_pos_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+
+ALTER TABLE `zh_stage_pos_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+ALTER TABLE `zh_stage_change`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_change_final`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_detail`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计量不计价' AFTER `unit_price`;