MaiXinRong 4 lat temu
rodzic
commit
8e6cb88eaf

+ 63 - 1
app/controller/setting_controller.js

@@ -1,4 +1,4 @@
-'use strict';
+ 'use strict';
 
 
 /**
 /**
  *
  *
@@ -15,6 +15,8 @@ const accountGroup = require('../const/account_group').group;
 const permission = require('../const/account_permission').permission;
 const permission = require('../const/account_permission').permission;
 const projectLog = require('../const/project_log');
 const projectLog = require('../const/project_log');
 const imType = require('../const/tender').imType;
 const imType = require('../const/tender').imType;
+const S2b = require('../lib/s2b');
+const measureType = require('../const/tender').measureType;
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -31,6 +33,13 @@ module.exports = app => {
             ctx.subMenu = settingMenu;
             ctx.subMenu = settingMenu;
         }
         }
 
 
+        _checkMenu(pid) {
+            const s2bData = new S2b(this.ctx);
+            const s2bProj = s2bData.getS2bProj(pid);
+            this.ctx.subMenu.s2b.display = s2bProj.gxby || s2bProj.dagl;
+            return s2bProj;
+        }
+
         /**
         /**
          * 项目信息页面(Get)
          * 项目信息页面(Get)
          *
          *
@@ -41,6 +50,7 @@ module.exports = app => {
             try {
             try {
                 // 获取项目数据
                 // 获取项目数据
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 if (projectData === null) {
                 if (projectData === null) {
                     throw '没有对应的项目数据';
                     throw '没有对应的项目数据';
@@ -85,6 +95,7 @@ module.exports = app => {
             try {
             try {
                 // 获取项目数据
                 // 获取项目数据
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 if (projectData === null) {
                 if (projectData === null) {
                     throw '没有对应的项目数据';
                     throw '没有对应的项目数据';
@@ -410,6 +421,7 @@ module.exports = app => {
             try {
             try {
                 // 获取项目数据
                 // 获取项目数据
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 if (projectData === null) {
                 if (projectData === null) {
                     throw '没有对应的项目数据';
                     throw '没有对应的项目数据';
@@ -626,6 +638,7 @@ module.exports = app => {
             try {
             try {
                 // 获取项目数据
                 // 获取项目数据
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 if (!projectData) {
                 if (!projectData) {
                     throw '没有对应的项目数据';
                     throw '没有对应的项目数据';
@@ -666,6 +679,7 @@ module.exports = app => {
             try {
             try {
                 // 获取项目数据
                 // 获取项目数据
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 if (projectData === null) {
                 if (projectData === null) {
                     throw '没有对应的项目数据';
                     throw '没有对应的项目数据';
@@ -692,6 +706,7 @@ module.exports = app => {
         async fun(ctx) {
         async fun(ctx) {
             try {
             try {
                 const projectId = ctx.session.sessionProject.id;
                 const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const projectData = await ctx.service.project.getDataById(projectId);
                 const funRela = await ctx.service.project.getFunRela(projectId);
                 const funRela = await ctx.service.project.getFunRela(projectId);
                 if (projectData === null) {
                 if (projectData === null) {
@@ -741,6 +756,53 @@ module.exports = app => {
                 this.ajaxErrorBody(error, '保存数据失败');
                 this.ajaxErrorBody(error, '保存数据失败');
             }
             }
         }
         }
+
+        async s2b (ctx) {
+            try {
+                const projectId = ctx.session.sessionProject.id;
+                this._checkMenu(projectId);
+                const projectData = await ctx.service.project.getDataById(projectId);
+                if (projectData === null) throw '没有对应的项目数据';
+                if (ctx.session.sessionUser.is_admin === 0) throw '没有访问权限';
+
+                const tenders = await ctx.service.tender.getAllDataByCondition({ where: { project_id: projectId } });
+                for (const t of tenders) {
+                    t.measure_type_str = t.measure_type === measureType.tz.value ? measureType.tz.title : measureType.gcl.title;
+                    const stages = await ctx.service.stage.getAllDataByCondition({ where: { tid: t.id } });
+                    t.stage_count_str = `第${stages.count || 0}期`;
+                    const user = await ctx.service.projectAccount.getAccountInfoById(t.user_id);
+                    t.user_str = user.name + '-' + user.company;
+                }
+                await this.layout('setting/s2b.ejs', {
+                    projectData,
+                    tenders,
+                })
+            } catch (error) {
+                ctx.helper.log(error);
+                ctx.redirect('/dashboard');
+            }
+        }
+
+        async s2bUpdate(ctx) {
+            try {
+                const projectId = ctx.session.sessionProject.id;
+                const projectData = await ctx.service.project.getDataById(projectId);
+                if (projectData === null) throw '没有对应的项目数据';
+                if (ctx.session.sessionUser.is_admin === 0) throw '没有访问权限';
+
+                const tenderId = parseInt(ctx.query.tid);
+                const updateData = {};
+                if (ctx.query.gxbyLimit) updateData.s2b_gxby_limit = ctx.query.gxbyLimit === '1';
+                if (ctx.query.gxbyCheck) updateData.s2b_gxby_check = ctx.query.gxbyCheck === '1';
+                if (ctx.query.daglLimit) updateData.s2b_dagl_limit = ctx.query.daglLimit === '1';
+                if (ctx.query.daglCheck) updateData.s2b_dagl_check = ctx.query.daglCheck === '1';
+                await ctx.service.tender.saveApiRela(tenderId, updateData);
+                ctx.redirect('/setting/api');
+            } catch (error) {
+                ctx.helper.log(error);
+                ctx.redirect('/setting/api');
+            }
+        }
     }
     }
 
 
     return SettingController;
     return SettingController;

+ 6 - 4
app/controller/stage_controller.js

@@ -358,6 +358,9 @@ module.exports = app => {
                 const ledgerData = await this._getStageLedgerData(ctx);
                 const ledgerData = await this._getStageLedgerData(ctx);
                 const posData = await this._getStagePosData(ctx);
                 const posData = await this._getStagePosData(ctx);
 
 
+                const checkDataModel = require('../lib/ledger').checkData;
+                const checkData = new checkDataModel(ctx);
+                const check3fResult = checkData.check3fLimit(ctx.tender.data, ledgerData, posData);
                 const [qtyData, overData] = ctx.helper.checkBillsWithPos2(ledgerData, posData,
                 const [qtyData, overData] = ctx.helper.checkBillsWithPos2(ledgerData, posData,
                     ['contract_qty', 'qc_qty'], projRela.banOver, this.ctx.tender.data.measure_type === measureType.tz.value);
                     ['contract_qty', 'qc_qty'], projRela.banOver, this.ctx.tender.data.measure_type === measureType.tz.value);
                 qtyData.error.forEach(x => { x.errorType = 'qty'; });
                 qtyData.error.forEach(x => { x.errorType = 'qty'; });
@@ -367,10 +370,10 @@ module.exports = app => {
                 ], this.ctx.tender.info.decimal);
                 ], this.ctx.tender.info.decimal);
                 tpData.error.forEach(x => { x.errorType = 'tp'; });
                 tpData.error.forEach(x => { x.errorType = 'tp'; });
                 ctx.body = { err: 0, msg: '', data: {
                 ctx.body = { err: 0, msg: '', data: {
-                    error: [...qtyData.error, ...tpData.error, ...overData.error],
+                    error: [...qtyData.error, ...tpData.error, ...overData.error, ...check3fResult.error],
                     source: {
                     source: {
-                        bills: [...qtyData.source.bills, ...tpData.source.bills, ...overData.source.bills],
-                        pos: [...qtyData.source.pos, ...tpData.source.pos, ...overData.source.pos],
+                        bills: ctx.helper._.uniqBy([...qtyData.source.bills, ...tpData.source.bills, ...overData.source.bills, ...check3fResult.source.bills], 'id'),
+                        pos: ctx.helper._.uniqBy([...qtyData.source.pos, ...tpData.source.pos, ...overData.source.pos, ...check3fResult.source.pos], 'id'),
                     },
                     },
                 } };
                 } };
             } catch (err) {
             } catch (err) {
@@ -1427,7 +1430,6 @@ module.exports = app => {
                     }
                     }
                 } catch (err) {
                 } catch (err) {
                     this.log(err);
                     this.log(err);
-                    console.log(err);
                     this.setMessage(err.toString(), this.messageType.ERROR);
                     this.setMessage(err.toString(), this.messageType.ERROR);
                 }
                 }
             }
             }

+ 5 - 5
app/extend/helper.js

@@ -1364,10 +1364,10 @@ module.exports = {
         return counts(array, val);
         return counts(array, val);
     },
     },
 
 
-    filterTimesOrderData(data, keyFields, times, order) {
+    filterTimesOrderData(data, keyFields, timesField, orderField, times, order) {
         const dataIndex = {};
         const dataIndex = {};
         for (const d of data) {
         for (const d of data) {
-            if (d.times > times || (d.times = times || d.order > order)) continue;
+            if (d[timesField] > times || (d[timesField] = times && d[orderField] > order)) continue;
             let key = 'd';
             let key = 'd';
             for (const kf of keyFields) {
             for (const kf of keyFields) {
                 key = key + '.' + (d[kf] || '');
                 key = key + '.' + (d[kf] || '');
@@ -1375,7 +1375,7 @@ module.exports = {
 
 
             const di = dataIndex[key];
             const di = dataIndex[key];
             if (di) {
             if (di) {
-                if ((di.times * timesLen + di.order) < (d.times * timesLen + d.order)) dataIndex[key] = d;
+                if ((di[timesField] * timesLen + di[orderField]) < (d[timesField] * timesLen + d[orderField])) dataIndex[key] = d;
             } else {
             } else {
                 dataIndex[key] = d;
                 dataIndex[key] = d;
             }
             }
@@ -1387,7 +1387,7 @@ module.exports = {
         return result;
         return result;
     },
     },
 
 
-    filterLastestData(data, keyFields) {
+    filterLastestData(data, keyFields, timesField = 'times', orderField = 'order') {
         const dataIndex = {};
         const dataIndex = {};
         for (const d of data) {
         for (const d of data) {
             let key = 'd';
             let key = 'd';
@@ -1397,7 +1397,7 @@ module.exports = {
 
 
             const di = dataIndex[key];
             const di = dataIndex[key];
             if (di) {
             if (di) {
-                if ((di.times * timesLen + di.order) < (d.times * timesLen + d.order)) dataIndex[key] = d;
+                if ((di[timesField] * timesLen + di[orderField]) < (d[timesField] * timesLen + d[orderField])) dataIndex[key] = d;
             } else {
             } else {
                 dataIndex[key] = d;
                 dataIndex[key] = d;
             }
             }

+ 130 - 0
app/lib/ledger.js

@@ -572,10 +572,140 @@ class pos {
     }
     }
 }
 }
 
 
+class checkData {
+    constructor(ctx) {
+        this.ctx = ctx;
+        this.checkBills = new billsTree(ctx, { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1 });
+        this.checkPos = new pos({ id: 'id', ledgerId: 'lid' });
+    }
+
+    _check3f(data, limit, ratio) {
+        if (limit === 0) {
+            if (data.contract_tp || data.pre_contract_tp) return 1; // 违规
+        }
+        if (limit === 1) {
+            if (ratio === 0) {
+                if (!data.contract_tp && !data.pre_contract_tp) return 2; // 漏计
+            } else {
+                const tp = this.ctx.helper.mul(data.total_price, ratio, this.ctx.tender.info.decimal.tp);
+                const checkTp = this.ctx.helper.add(data.contract_tp, data.pre_contract_tp);
+                if (tp > checkTp) return 1; // 违规
+                if (tp < checkTp) return 2; // 漏计
+            }
+        }
+        return 0; // 合法
+    }
+    _check3fQty(data, limit, ratio, unit) {
+        if (limit === 0) {
+            if (data.contract_qty || data.qc_qty || data.pre_contract_qty || data.pre_qc_qty) return 1; // 违规
+        }
+        if (limit === 1) {
+            if (ratio === 0) {
+                if (!data.contract_qty && data.qc_qty && !data.pre_contract_qty && !data.pre_qc_qty) return 2; // 漏计
+            } else {
+                const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, unit);
+                const checkQty = this.ctx.helper.mul(data.quantity, ratio, precision.value);
+                const qty = this.ctx.helper.add(data.contract_qty, data.pre_contract_qty);
+                if (qty > checkQty) return 1; // 违规
+                if (qty < checkQty) return 2; // 漏计
+            }
+        }
+        return 0; // 合法
+    }
+
+    _checkLeafBills3fLimit(checkType, bills, result, checkInfo) {
+        const over = [], lost = [];
+        const posRange = this.checkPos.getLedgerPos(bills.id);
+        if (posRange && posRange.length > 0) {
+            for (const p of posRange) {
+                for (const ct of checkType) {
+                    const checkResult = bills.is_tp
+                        ? this._check3f(p, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'])
+                        : this._check3fQty(p, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'], bills.unit);
+                    if (checkResult === 1) {
+                        if (over.indexOf(ct) === -1) over.push(ct);
+                    }
+                    if (checkResult === 2) {
+                        if (lost.indexOf(ct) === -1) lost.push(ct);
+                    }
+                }
+            }
+        } else {
+            for (const ct of checkType) {
+                const checkResult = bills.is_tp
+                    ? this._check3f(bills, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'])
+                    : this._check3fQty(bills, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'], bills.unit);
+                if (checkResult === 1) {
+                    if (over.indexOf(ct) === -1) over.push(ct);
+                }
+                if (checkResult === 2) {
+                    if (lost.indexOf(ct) === -1) lost.push(ct);
+                }
+            }
+        }
+        if (over.length + lost.length > 0) {
+            for (const o of over) {
+                result.error.push({
+                    ledger_id: bills.ledger_id,
+                    b_code: bills.b_code,
+                    name: bills.name,
+                    errorType: 's2b_over_' + o,
+                });
+            }
+            for (const l of lost) {
+                result.error.push({
+                    ledger_id: bills.ledger_id,
+                    b_code: bills.b_code,
+                    name: bills.name,
+                    errorType: 's2b_lost_' + l,
+                });
+            }
+            result.source.bills.push(bills);
+            if (posRange && posRange.length > 0) result.source.pos.push(...posRange);
+        }
+    }
+    _recursiveCheckBills3fLimit(checkType, bills, result, parentCheckInfo) {
+        const checkInfo = this.ctx.helper._.assign({}, parentCheckInfo);
+        for (const ct of checkType) {
+            if (bills[ct + '_limit'] >= 0) {
+                checkInfo[ct + '_limit'] = bills[ct + '_limit'];
+                checkInfo[ct + '_ratio'] = bills[ct + '_ratio'];
+            }
+        }
+        if (bills.children && bills.children.length > 0) {
+            for (const c of bills.children) {
+                this._recursiveCheckBills3fLimit(checkType, c, result, checkInfo);
+            }
+        } else {
+            this._checkLeafBills3fLimit(checkType, bills, result, checkInfo);
+        }
+    }
+    check3fLimit(tender, bills, pos) {
+        const result = {
+            error: [],
+            source: {bills: [], pos: []},
+        };
+
+        const check = [];
+        if (tender.s2b_gxby_limit) check.push('gxby');
+        if (tender.s2b_dagl_limit) check.push('dagl');
+        if (check.length === 0) return result;
+
+        this.checkBills.loadDatas(bills);
+        this.checkPos.loadDatas(pos);
+
+        for (const b of this.checkBills.children) {
+            this._recursiveCheckBills3fLimit(check, b, result, {});
+        }
+        return result;
+    }
+}
+
 module.exports = {
 module.exports = {
     billsTree,
     billsTree,
     pos,
     pos,
     filterTree,
     filterTree,
     filterGatherTree,
     filterGatherTree,
     gatherTree,
     gatherTree,
+    checkData,
 };
 };

+ 2 - 1
app/lib/rptCustomData.js

@@ -297,8 +297,9 @@ class jhHelper {
         // 查询比较人数据
         // 查询比较人数据
         this.prefixes = [];
         this.prefixes = [];
         const stageChangeDetail = await this.getCurChangeDetailData(tender.id, stage.id);
         const stageChangeDetail = await this.getCurChangeDetailData(tender.id, stage.id);
+        this.ctx.helper.saveBufferFile(JSON.stringify(stageChangeDetail, '', '\t'), this.ctx.app.baseDir + '/temp.json');
         for (const dc of gsDefine.defaultCompare) {
         for (const dc of gsDefine.defaultCompare) {
-            const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cid', 'cbid'], auditors[dc].times, auditors[dc].order);
+            const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder', auditors[dc].times, auditors[dc].order);
             this._loadChangeDetail(billsIndex, scd, gsDefine, `r${dc}_`);
             this._loadChangeDetail(billsIndex, scd, gsDefine, `r${dc}_`);
             this.prefixes.push(`r${dc}_`);
             this.prefixes.push(`r${dc}_`);
         }
         }

+ 22 - 0
app/lib/s2b.js

@@ -0,0 +1,22 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+class S2b {
+    constructor(ctx) {
+        this.ctx = ctx;
+        this.db = ctx.app.mysql;
+    }
+
+    getS2bProj(pid) {
+        return this.db.get('zh_s2b_proj', { pid });
+    }
+};
+
+module.exports = S2b;

+ 136 - 5
app/public/js/ledger_check.js

@@ -17,6 +17,14 @@ const ledgerCheckType = {
     tp: {value: 5, text: '清单金额≠数量×单价', fun: 'checkTp', },
     tp: {value: 5, text: '清单金额≠数量×单价', fun: 'checkTp', },
     over: {value: 6, text: '超计', fun: 'checkOver', },
     over: {value: 6, text: '超计', fun: 'checkOver', },
     same_code: {value: 7, text: '重复项目节', fun: 'checkSameCode', },
     same_code: {value: 7, text: '重复项目节', fun: 'checkSameCode', },
+    limit3f: {
+        fun: 'check3fLimit', items: [
+            { value: 8, text: '违规计量(工序报验)', key: 'gxbyOver', type: 'gxby', },
+            { value: 9, text: '遗漏计量(工序报验)', key: 'gxbyLost', type: 'gxby', },
+            { value: 10, text: '违规计量(档案管理)', key: 'daglOver', type: 'dagl', },
+            { value: 11, text: '遗漏计量(档案管理)', key: 'daglLost', type: 'dagl', },
+        ]
+    },
 };
 };
 const ledgerCheckUtil = {
 const ledgerCheckUtil = {
     checkSibling: function (ledgerTree, ledgerPos, decimal, option) {
     checkSibling: function (ledgerTree, ledgerPos, decimal, option) {
@@ -118,7 +126,115 @@ const ledgerCheckUtil = {
             }
             }
         }
         }
         return error;
         return error;
-    }
+    },
+    check3fLimit: function (ledgerTree, ledgerPos, decimal, option) {
+        const error = {};
+        for (const i of ledgerCheckType.limit3f.items) {
+            error[i.key] = [];
+        }
+        if (option.checkType.length === 0) return error;
+
+        const findPrecision = function (list, unit) {
+            if (unit) {
+                for (const p in list) {
+                    if (list[p].unit && list[p].unit === unit) {
+                        return list[p];
+                    }
+                }
+            }
+            return list.other;
+        };
+        const check3f = function (data, limit, ratio) {
+            if (limit === 0) {
+                if (data.contract_tp || data.pre_contract_tp) return 1; // 违规
+            }
+            if (limit === 1) {
+                if (ratio === 0) {
+                    if (!data.contract_tp && !data.pre_contract_tp) return 2; // 漏计
+                } else {
+                    const tp = ZhCalc.mul(data.total_price, ratio, this.ctx.tender.info.decimal.tp);
+                    const checkTp = ZhCalc.add(data.contract_tp, data.pre_contract_tp);
+                    if (tp > checkTp) return 1; // 违规
+                    if (tp < checkTp) return 2; // 漏计
+                }
+            }
+            return 0; // 合法
+        };
+        const check3fQty = function (data, limit, ratio, unit) {
+            if (limit === 0) {
+                if (data.contract_qty || data.qc_qty || data.pre_contract_qty || data.pre_qc_qty) return 1; // 违规
+            }
+            if (limit === 1) {
+                if (ratio <= 0) {
+                    if (!data.contract_qty && data.qc_qty && !data.pre_contract_qty && !data.pre_qc_qty) return 2; // 漏计
+                } else {
+                    const precision = findPrecision(tenderInfo.precision, unit);
+                    const checkQty = ZhCalc.mul(data.quantity, ratio, precision.value);
+                    const qty = ZhCalc.add(data.contract_qty, data.pre_contract_qty);
+                    if (qty > checkQty) return 1; // 违规
+                    if (qty < checkQty) return 2; // 漏计
+                }
+            }
+            return 0; // 合法
+        };
+        const checkLeafBills3fLimit = function(bills, checkInfo) {
+            const over = [], lost = [];
+            const posRange = ledgerPos.getLedgerPos(bills.id);
+            if (posRange && posRange.length > 0) {
+                for (const p of posRange) {
+                    for (const ct of option.checkType) {
+                        const checkResult = bills.is_tp
+                            ? check3f(p, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'])
+                            : check3fQty(p, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'], bills.unit);
+                        if (checkResult === 1) {
+                            if (over.indexOf(ct) === -1) over.push(ct);
+                        }
+                        if (checkResult === 2) {
+                            if (lost.indexOf(ct) === -1) lost.push(ct);
+                        }
+                    }
+                }
+            } else {
+                for (const ct of option.checkType) {
+                    const checkResult = bills.is_tp
+                        ? check3f(bills, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'])
+                        : check3fQty(bills, checkInfo[ct + '_limit'], checkInfo[ct + '_ratio'], bills.unit);
+                    if (checkResult === 1) {
+                        if (over.indexOf(ct) === -1) over.push(ct);
+                    }
+                    if (checkResult === 2) {
+                        if (lost.indexOf(ct) === -1) lost.push(ct);
+                    }
+                }
+            }
+
+            if (over.indexOf('gxby') >= 0) error.gxbyOver.push(bills);
+            if (over.indexOf('dagl') >= 0) error.daglOver.push(bills);
+            if (lost.indexOf('gxby') >= 0) error.gxbyLost.push(bills);
+            if (lost.indexOf('dagl') >= 0) error.daglLost.push(bills);
+        };
+        const recursiveCheckBills3fLimit = function (bills, parentCheckInfo) {
+            const checkInfo = _.assign({}, parentCheckInfo);
+            for (const ct of option.checkType) {
+                if (bills[ct + '_limit'] >= 0) {
+                    checkInfo[ct + '_limit'] = bills[ct + '_limit'];
+                    checkInfo[ct + '_ratio'] = bills[ct + '_ratio'];
+                }
+            }
+            if (bills.children && bills.children.length > 0) {
+                for (const c of bills.children) {
+                    recursiveCheckBills3fLimit(c, checkInfo);
+                }
+            } else {
+                checkLeafBills3fLimit(bills, checkInfo);
+            }
+        };
+
+        for (const b of ledgerTree.children) {
+            recursiveCheckBills3fLimit(b, {});
+        }
+        return error;
+    },
 };
 };
 
 
 const ledgerCheck2 = function (setting) {
 const ledgerCheck2 = function (setting) {
@@ -145,9 +261,18 @@ const ledgerCheck2 = function (setting) {
     for (const prop in ledgerCheckType) {
     for (const prop in ledgerCheckType) {
         if (!checkOption[prop] || !checkOption[prop].enable) continue;
         if (!checkOption[prop] || !checkOption[prop].enable) continue;
 
 
-        const errors = ledgerCheckUtil[ledgerCheckType[prop].fun](ledger, ledgerPos, decimal, checkOption[prop]) || [];
-        assignWarningData(errors, ledgerCheckType[prop].value, checkData.warning_data);
-        progressData.push({key: prop, caption: ledgerCheckType[prop].text, error: errors.length});
+        if (ledgerCheckType[prop].items) {
+            const errors = ledgerCheckUtil[ledgerCheckType[prop].fun](ledger, ledgerPos, decimal, checkOption[prop]) || {};
+            for (const i of ledgerCheckType[prop].items) {
+                if (checkOption[prop].checkType.indexOf(i.type) < 0) continue;
+                assignWarningData(errors[i.key], i.value, checkData.warning_data);
+                progressData.push({key: prop + i.key, caption: i.text, error: errors[i.key].length});
+            }
+        } else {
+            const errors = ledgerCheckUtil[ledgerCheckType[prop].fun](ledger, ledgerPos, decimal, checkOption[prop]) || [];
+            assignWarningData(errors, ledgerCheckType[prop].value, checkData.warning_data);
+            progressData.push({key: prop, caption: ledgerCheckType[prop].text, error: errors.length});
+        }
     }
     }
     setting.checkList.clearCheckData();
     setting.checkList.clearCheckData();
     if (checkData.warning_data.length > 0) {
     if (checkData.warning_data.length > 0) {
@@ -161,7 +286,13 @@ const getCheckType = function (option) {
     const result = {};
     const result = {};
     for (const o in option) {
     for (const o in option) {
         if (option[o].enable) {
         if (option[o].enable) {
-            result[o] = ledgerCheckType[o];
+            if (ledgerCheckType[o].items) {
+                for (const i of ledgerCheckType[o].items) {
+                    result[o + i.key] = i;
+                }
+            } else {
+                result[o] = ledgerCheckType[o];
+            }
         }
         }
     }
     }
     return result;
     return result;

+ 4 - 0
app/public/js/shares/cs_tools.js

@@ -76,6 +76,10 @@ const showSelectTab = function(select, spread, afterShow) {
                                 case 'qty': return '数量';
                                 case 'qty': return '数量';
                                 case 'tp': return '金额';
                                 case 'tp': return '金额';
                                 case 'over': return '超计';
                                 case 'over': return '超计';
+                                case 's2b_over_gxby': return '违规计量(工序报验)';
+                                case 's2b_over_dagl': return '违规计量(档案管理)';
+                                case 's2b_lost_gxby': return '遗漏计量(工序报验)';
+                                case 's2b_lost_dagl': return '遗漏计量(档案管理)';
                                 default: return '';
                                 default: return '';
                             }
                             }
                         }
                         }

+ 5 - 0
app/public/js/stage.js

@@ -240,8 +240,13 @@ $(document).ready(() => {
         },
         },
         over: {
         over: {
             enable: 1, isTz: checkTzMeasureType(),
             enable: 1, isTz: checkTzMeasureType(),
+        },
+        limit3f: {
+            enable: 1, checkType: [],
         }
         }
     };
     };
+    if (tender.s2b_gxby_check) checkOption.limit3f.checkType.push('gxby');
+    if (tender.s2b_dagl_check) checkOption.limit3f.checkType.push('dagl');
     // 界面布局
     // 界面布局
     autoFlashHeight();
     autoFlashHeight();
     // 初始化 台账树结构 数据结构
     // 初始化 台账树结构 数据结构

+ 3 - 0
app/router.js

@@ -88,6 +88,9 @@ module.exports = app => {
     // 功能设置
     // 功能设置
     app.get('/setting/fun', sessionAuth, 'settingController.fun');
     app.get('/setting/fun', sessionAuth, 'settingController.fun');
     app.post('/setting/fun/update', sessionAuth, 'settingController.updateFun');
     app.post('/setting/fun/update', sessionAuth, 'settingController.updateFun');
+    // 接口设置
+    app.get('/setting/api', sessionAuth, 'settingController.s2b');
+    app.post('/setting/api/update', sessionAuth, 'settingController.s2bUpdate');
 
 
 
 
     // 项目相关
     // 项目相关

+ 2 - 4
app/service/stage.js

@@ -133,10 +133,8 @@ module.exports = app => {
             }
             }
 
 
             let time = stage.readOnly ? stage.cache_time_r : stage.cache_time_l;
             let time = stage.readOnly ? stage.cache_time_r : stage.cache_time_l;
-            if (!time) {
-                time = stage.in_time ? stage.in_time : new Date();
-            }
-            stage.cacheTime = time.getTime();// this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
+            if (!time) time = stage.in_time ? stage.in_time : new Date();
+            stage.cacheTime = time.getTime();
 
 
             return stage;
             return stage;
         }
         }

+ 1 - 1
app/service/stage_change_final.js

@@ -38,7 +38,7 @@ module.exports = app => {
                 '    s.order As s_order' +
                 '    s.order As s_order' +
                 '  FROM ' + this.tableName + ' cf' +
                 '  FROM ' + this.tableName + ' cf' +
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
-                '  Left Join ' + this.ctx.service.stage.tableName + ' c ON cf.sid = s.id' +
+                '  Left Join ' + this.ctx.service.stage.tableName + ' s ON cf.sid = s.id' +
                 '  Where cf.tid = ?';
                 '  Where cf.tid = ?';
             return await this.db.query(sql, [tid]);
             return await this.db.query(sql, [tid]);
         }
         }

+ 8 - 1
app/service/tender.js

@@ -13,7 +13,10 @@ const auditConst = require('../const/audit');
 const projectLogConst = require('../const/project_log');
 const projectLogConst = require('../const/project_log');
 const fs = require('fs');
 const fs = require('fs');
 const path = require('path');
 const path = require('path');
-const commonQueryColumns = ['id', 'project_id', 'name', 'status', 'category', 'ledger_times', 'ledger_status', 'measure_type', 'user_id', 'valuation', 'total_price', 'deal_tp', 'copy_id'];
+const commonQueryColumns = [
+    'id', 'project_id', 'name', 'status', 'category', 'ledger_times', 'ledger_status', 'measure_type', 'user_id', 'valuation',
+    'total_price', 'deal_tp', 'copy_id', 's2b_gxby_check', 's2b_gxby_limit', 's2b_dagl_check', 's2b_dagl_limit'
+];
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -412,6 +415,10 @@ module.exports = app => {
             }
             }
         }
         }
 
 
+        async saveApiRela(tid, updateData) {
+            console.log(tid, updateData);
+            await this.db.update(this.tableName, updateData, {where: { id: tid } });
+        }
     }
     }
 
 
     return Tender;
     return Tender;

+ 81 - 0
app/view/setting/s2b.ejs

@@ -0,0 +1,81 @@
+<% include ./sub_menu.ejs %>
+<div class="panel-content">
+    <div class="panel-title">
+        <div class="title-main">
+            <h2>API设置</h2>
+        </div>
+    </div>
+    <div class="content-wrap">
+        <div class="c-body">
+            <div class="sjs-height-0">
+                <% if (tenders.length === 0) { %>
+                <div class="jumbotron m-3">
+                    <h3 class="display-6">没有标段数据</h3>
+                </div>
+                <% } else { %>
+                <div class="m-3">
+                    <table class="table table-hover table-bordered">
+                        <thead>
+                        <tr>
+                            <th class="text-center" >名称</th>
+                            <th class="text-center" >计量模式</th>
+                            <th class="text-center" >计量期数</th>
+                            <th class="text-center" >创建人</th>
+                            <th class="text-center" >标段创建时间/期审批时间</th>
+                            <th class="text-center">工序报验</th>
+                            <th class="text-center">档案管理</th>
+                        </tr>
+                        </thead>
+                        <% for (const t of tenders) { %>
+                        <tr>
+                            <td><%- t.name %></td>
+                            <td><%- t.measure_type_str %></td>
+                            <td><%- t.stage_count_str %></td>
+                            <td><%- t.user_str %></td>
+                            <td><%- ctx.moment(t.show_time).format('YYY-MM-DD HH:mm:ss') %></td>
+                            <td class="text-center">
+                                <form action="api/update?tid=<%= t.id %>&gxbyCheck=<%- (t.s2b_gxby_check ? 0 : 1) %>" method="post">
+                                    <div class="form-check form-check-inline">
+                                        <input class="form-check-input" type="checkbox" id="inlineCheckbox1" <% if (t.s2b_gxby_check) { %>checked<% } %> name="gxby_check" onchange="submit();">
+                                        <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                                        <label class="form-check-label" for="inlineCheckbox1">检查计量</label>
+                                    </div>
+                                </form>
+                                <form action="api/update?tid=<%= t.id %>&gxbyLimit=<%- (t.s2b_gxby_limit ? 0 : 1) %>" method="post">
+                                    <div class="form-check form-check-inline">
+                                        <input class="form-check-input" type="checkbox" id="inlineCheckbox2" <% if (t.s2b_gxby_limit) { %>checked<% } %> name="gxby_limit" onchange="submit();">
+                                        <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                                        <label class="form-check-label" for="inlineCheckbox2">限制上报</label>
+                                    </div>
+                                </form>
+                            </td>
+                            <td class="text-center">
+                                <form action="api/update?tid=<%= t.id %>&daglCheck=<%- (t.s2b_dagl_check ? 0 : 1) %>" method="post">
+                                    <div class="form-check form-check-inline">
+                                        <input class="form-check-input" type="checkbox" id="inlineCheckbox3" <% if (t.s2b_dagl_check) { %>checked<% } %> name="dagl_check" onchange="submit();">
+                                        <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                                        <label class="form-check-label" for="inlineCheckbox3">检查计量</label>
+                                    </div>
+                                </form>
+                                <form action="api/update?tid=<%= t.id %>&daglLimit=<%- (t.s2b_dagl_limit ? 0 : 1) %>" method="post">
+                                    <div class="form-check form-check-inline">
+                                        <input class="form-check-input" type="checkbox" id="inlineCheckbox4" <% if (t.s2b_dagl_limit) { %>checked<% } %> name="dagl_limit" onchange="submit();">
+                                        <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                                        <label class="form-check-label" for="inlineCheckbox4">限制上报</label>
+                                    </div>
+                                </form>
+                            </td>
+                        </tr>
+                        <% } %>
+                    </table>
+                </div>
+                <% } %>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    $(() => {
+        autoFlashHeight();
+    })
+</script>

+ 6 - 0
config/menu.js

@@ -279,6 +279,12 @@ const settingMenu = {
         url: '/setting/category',
         url: '/setting/category',
         caption: '标段自定义类别',
         caption: '标段自定义类别',
     },
     },
+    s2b: {
+        name: '接口设置',
+        display: false,
+        url: '/setting/api',
+        caption: '接口设置',
+    },
     log: {
     log: {
         name: '操作日志',
         name: '操作日志',
         display: true,
         display: true,

+ 179 - 0
sql/update.sql

@@ -32,3 +32,182 @@ ADD COLUMN `s2b_gxby_limit`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '限
 ADD COLUMN `s2b_dagl_check`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '档案管理-检查计量' AFTER `s2b_gxby_limit`,
 ADD COLUMN `s2b_dagl_check`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '档案管理-检查计量' AFTER `s2b_gxby_limit`,
 ADD COLUMN `s2b_dagl_limit`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '档案管理-限制上报' AFTER `s2b_dagl_check`;
 ADD COLUMN `s2b_dagl_limit`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '档案管理-限制上报' AFTER `s2b_dagl_check`;
 
 
+ALTER TABLE `zh_pos_0`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_1`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_2`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_3`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_4`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_5`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_6`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_7`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_8`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_9`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_10`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_11`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_12`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_13`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_14`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_15`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_16`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_17`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_18`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_pos_19`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_0`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_1`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_2`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_3`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_4`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_5`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_6`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_7`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_8`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;
+
+ALTER TABLE `zh_ledger_9`
+ADD COLUMN `gxby_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `gxby_status`,
+ADD COLUMN `gxby_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `gxby_limit`,
+ADD COLUMN `dagl_limit`  int(4) NOT NULL DEFAULT -1 COMMENT '计量是否受限,-1不受限,0受限不可计量,1受限可计量' AFTER `dagl_status`,
+ADD COLUMN `dagl_ratio`  decimal(6,4) NOT NULL DEFAULT 0 COMMENT '允许计量比例,-1表示不限制' AFTER `dagl_limit`;