Kaynağa Gözat

修改期台账获取方式和整合

laiguoran 4 yıl önce
ebeveyn
işleme
20fee47fef

+ 86 - 86
app/controller/schedule_controller.js

@@ -112,46 +112,8 @@ module.exports = app => {
         async stageTp(ctx) {
             const tender = ctx.tender;
             const schedule = await ctx.service.schedule.getDataByCondition({ tid: tender.id });
-            const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
-            const stageOrderList = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 's_time', 'order'], where: { tid: tender.id } });
-            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
-            let curScheduleStage = scheduleStage.length > 0 ? _.maxBy(scheduleStage, 'order') : null;
-            let slmList = [];
-            let nextSlmList = [];
-            let endSlmList = [];
-            let yearSlmList = [];
-            let curYearStageData = [];
-            if (ctx.params.order && scheduleStage.length > 0) {
-                curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
-            }
-            if (curScheduleStage) {
-                // const newSS = _.sortBy(scheduleStage, 'yearmonth');
-                const newSM = _.sortBy(scheduleMonth, 'yearmonth');
-                const nowScheduleStage = _.findIndex(newSM, { yearmonth: curScheduleStage.yearmonth });
-                slmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: curScheduleStage.yearmonth } });
-                const nextScheduleStage = nowScheduleStage >= 0 && nowScheduleStage + 1 <= newSM.length - 1 ? newSM[nowScheduleStage + 1] : null;
-                if (nextScheduleStage) nextSlmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: nextScheduleStage.yearmonth } });
-                if (nowScheduleStage === 0) {
-                    endSlmList = slmList;
-                } else if (nowScheduleStage > 0) {
-                    const endYearmonthCollection = _.map(_.take(newSM, nowScheduleStage + 1), 'yearmonth');
-                    endSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, endYearmonthCollection);
-                }
-                const yearConllection = _.map(_.filter(newSM, function(item) {
-                    return item.yearmonth.indexOf(curScheduleStage.yearmonth.split('-')[0]) !== -1;
-                }), 'yearmonth');
-                yearSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, yearConllection);
-                // 获取本年完成计量数据
-                const curStage = _.find(stageOrderList, { order: curScheduleStage.order });
-                const stageList = _.filter(stageOrderList, function(item) {
-                    return item.s_time.indexOf(curStage.s_time.split('-')[0]) !== -1;
-                });
-                const newSS = _.sortBy(scheduleStage, 'yearmonth');
-                const stageIdList = _.map(_.filter(stageList, function(item) {
-                    return _.find(newSS, { order: item.order });
-                }), 'id');
-                curYearStageData = await ctx.service.stageBills.getStagesData(ctx.tender.id, stageIdList.join(','));
-            }
+            const { slmList, nextSlmList, endSlmList, yearSlmList, curYearStageData,
+                scheduleMonth, stageOrderList, scheduleStage, curScheduleStage } = await this._getStageAndPlanData(ctx);
             const renderData = {
                 tender: tender.data,
                 tenderInfo: tender.info,
@@ -202,59 +164,97 @@ module.exports = app => {
          */
         async loadTpLedgerData(ctx) {
             try {
-                const tender = ctx.tender;
-                // const ledgerData = await ctx.controller.stage._getStageLedgerData(ctx);
-                // console.log(ledgerData);
-                const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
-                const stageOrderList = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 's_time', 'order'], where: { tid: tender.id } });
-                const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
-                const curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
-                let slmList = [];
-                let nextSlmList = [];
-                let endSlmList = [];
-                let yearSlmList = [];
-                let curYearStageData = [];
-                if (curScheduleStage) {
-                    const newSM = _.sortBy(scheduleMonth, 'yearmonth');
-                    const nowScheduleStage = _.findIndex(newSM, { yearmonth: curScheduleStage.yearmonth });
-                    slmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: curScheduleStage.yearmonth } });
-                    const nextScheduleStage = nowScheduleStage >= 0 && nowScheduleStage + 1 <= newSM.length - 1 ? newSM[nowScheduleStage + 1] : null;
-                    if (nextScheduleStage) nextSlmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: nextScheduleStage.yearmonth } });
-                    if (nowScheduleStage === 0) {
-                        endSlmList = slmList;
-                    } else if (nowScheduleStage > 0) {
-                        const endYearmonthCollection = _.map(_.take(newSM, nowScheduleStage + 1), 'yearmonth');
-                        endSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, endYearmonthCollection);
-                    }
-                    const yearConllection = _.map(_.filter(newSM, function(item) {
-                        return item.yearmonth.indexOf(curScheduleStage.yearmonth.split('-')[0]) !== -1;
-                    }), 'yearmonth');
-                    yearSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, yearConllection);
-                    // 获取本年完成计量数据
-                    const curStage = _.find(stageOrderList, { order: curScheduleStage.order });
-                    const stageList = _.filter(stageOrderList, function(item) {
-                        return item.s_time.indexOf(curStage.s_time.split('-')[0]) !== -1;
-                    });
-                    const newSS = _.sortBy(scheduleStage, 'yearmonth');
-                    const stageIdList = _.map(_.filter(stageList, function(item) {
-                        return _.find(newSS, { order: item.order });
-                    }), 'id');
-                    curYearStageData = await ctx.service.stageBills.getStagesData(tender.id, stageIdList.join(','));
+                const ledgerData = await this._getStageLedgerData(ctx, ctx.params.order);
+                const postData = { ledgerData };
+                const data = JSON.parse(ctx.request.body.data);
+                if (data.filter && data.filter === 'gcl') {
+                    const { slmList, nextSlmList, endSlmList, yearSlmList, curYearStageData } = await this._getStageAndPlanData(ctx);
+                    _.assignIn(postData, { slmList, nextSlmList, endSlmList, yearSlmList, curYearStageData });
                 }
-                ctx.body = { err: 0, msg: '', data: {
-                    // ledgerData,
-                    slmList,
-                    nextSlmList,
-                    endSlmList,
-                    yearSlmList,
-                    curYearStageData,
-                } };
+                ctx.body = { err: 0, msg: '', data: postData };
             } catch (err) {
                 this.log(err);
                 ctx.body = { err: 1, msg: err.toString(), data: [] };
             }
         }
 
+        async _getStageLedgerData(ctx, stageOrder) {
+            const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);
+            const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
+            for (const d of dgnData) {
+                const l = ctx.app._.find(ledgerData, { id: d.id });
+                ctx.app._.assignIn(l, d);
+            }
+            const stageInfo = await ctx.service.stage.getDataByCondition({
+                tid: ctx.tender.id,
+                order: stageOrder,
+            });
+            let preStageData;
+            // 当前操作人查看最新数据,其他人查看历史数据
+            const curStageData = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, stageInfo.id);
+            // 查询截止上期数据
+            if (stageInfo.order > 1) {
+                preStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, stageInfo.order - 1);
+            } else {
+                preStageData = [];
+            }
+            this.ctx.helper.assignRelaData(ledgerData, [
+                { 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' },
+            ]);
+            return ledgerData;
+        }
+
+        /**
+         * 获取本期下台账计量和计划数据(Ajax)
+         *
+         * @param ctx
+         * @return {Promise<void>}
+         */
+        async _getStageAndPlanData(ctx) {
+            const tender = ctx.tender;
+            const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
+            const stageOrderList = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 's_time', 'order'], where: { tid: tender.id } });
+            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
+            let curScheduleStage = scheduleStage.length > 0 ? _.maxBy(scheduleStage, 'order') : null;
+            if (ctx.params.order && scheduleStage.length > 0) {
+                curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
+            }
+            let slmList = [];
+            let nextSlmList = [];
+            let endSlmList = [];
+            let yearSlmList = [];
+            let curYearStageData = [];
+            if (curScheduleStage) {
+                const newSM = _.sortBy(scheduleMonth, 'yearmonth');
+                const nowScheduleStage = _.findIndex(newSM, { yearmonth: curScheduleStage.yearmonth });
+                slmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: curScheduleStage.yearmonth } });
+                const nextScheduleStage = nowScheduleStage >= 0 && nowScheduleStage + 1 <= newSM.length - 1 ? newSM[nowScheduleStage + 1] : null;
+                if (nextScheduleStage) nextSlmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: nextScheduleStage.yearmonth } });
+                if (nowScheduleStage === 0) {
+                    endSlmList = slmList;
+                } else if (nowScheduleStage > 0) {
+                    const endYearmonthCollection = _.map(_.take(newSM, nowScheduleStage + 1), 'yearmonth');
+                    endSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, endYearmonthCollection);
+                }
+                const yearConllection = _.map(_.filter(newSM, function(item) {
+                    return item.yearmonth.indexOf(curScheduleStage.yearmonth.split('-')[0]) !== -1;
+                }), 'yearmonth');
+                yearSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, yearConllection);
+                // 获取本年完成计量数据
+                const curStage = _.find(stageOrderList, { order: curScheduleStage.order });
+                const stageList = _.filter(stageOrderList, function(item) {
+                    return item.s_time.indexOf(curStage.s_time.split('-')[0]) !== -1;
+                });
+                const newSS = _.sortBy(scheduleStage, 'yearmonth');
+                const stageIdList = _.map(_.filter(stageList, function(item) {
+                    return _.find(newSS, { order: item.order });
+                }), 'id');
+                curYearStageData = await ctx.service.stageBills.getStagesData(tender.id, stageIdList.join(','));
+            }
+            return { slmList, nextSlmList, endSlmList, yearSlmList, curYearStageData, scheduleMonth, stageOrderList, scheduleStage, curScheduleStage };
+        }
+
         /**
          * 获取台账数据(Ajax)
          *

+ 1 - 3
app/middleware/stage_check.js

@@ -60,9 +60,7 @@ module.exports = options => {
             });
             // 权限相关
             // todo 校验权限 (标段参与人、分享)
-            // 因为进度需要,暂时先处理所有accountId都为原报本人,才能获取到所有期数据,之后调整吧
-            const data = this.request.body.data ? JSON.parse(this.request.body.data) : null;
-            const accountId = data && data.comefrom && data.comefrom === 'schedule' ? stage.user_id : this.session.sessionUser.accountId,
+            const accountId = this.session.sessionUser.accountId,
                 auditorIds = _.map(stage.auditors, 'aid'),
                 shareIds = [];
             stage.users = stage.status === status.uncheck ? [stage.user_id] : [stage.user_id, ...auditorIds];

+ 61 - 63
app/public/js/schedule_stage_gcl.js

@@ -369,72 +369,70 @@ $(function () {
 
     const huizongObj = {
         setSjs: function (order) {
-            postData('/tender/' + getTenderId() + '/measure/stage/' + order + '/load', { filter: 'ledger', comefrom: 'schedule' }, function (data) {
-                postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {}, function (data2) {
-                    const calcList = ['year_gather_tp',
-                        'contract_tp', 'qc_qty', 'qc_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'];
-                    const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
-                        'year_contract_qty', 'year_gather_tp',
-                        'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
-                        'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', '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'];
-                    const baseLedgerTreeSetting = {
-                        id: 'ledger_id',
-                        pid: 'ledger_pid',
-                        order: 'order',
-                        level: 'level',
-                        rootId: -1,
-                        fullPath: 'full_path',
-                        calcFields: calcList,
-                    };
-                    baseLedgerTreeSetting.updateFields = ['year_contract_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
-                    baseLedgerTreeSetting.calcFun = function (node) {
-                        if (!node.children || node.children.length === 0) {
-                            node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
-                            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_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);
-                        node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
-                        node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
-                        node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
-                        node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
-                        node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
-                        if (!node.children || node.children.length === 0) {
-                            if (node.end_contract_qty) {
-                                node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
-                            } else {
-                                node.end_correct_tp = node.end_gather_tp;
-                            }
+            postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {filter: 'gcl' }, function (data) {
+                const calcList = ['year_gather_tp',
+                    'contract_tp', 'qc_qty', 'qc_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'];
+                const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
+                    'year_contract_qty', 'year_gather_tp',
+                    'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
+                    'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', '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'];
+                const baseLedgerTreeSetting = {
+                    id: 'ledger_id',
+                    pid: 'ledger_pid',
+                    order: 'order',
+                    level: 'level',
+                    rootId: -1,
+                    fullPath: 'full_path',
+                    calcFields: calcList,
+                };
+                baseLedgerTreeSetting.updateFields = ['year_contract_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+                baseLedgerTreeSetting.calcFun = function (node) {
+                    if (!node.children || node.children.length === 0) {
+                        node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
+                        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_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);
+                    node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
+                    node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
+                    node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
+                    node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
+                    node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
+                    if (!node.children || node.children.length === 0) {
+                        if (node.end_contract_qty) {
+                            node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
+                        } else {
+                            node.end_correct_tp = node.end_gather_tp;
                         }
-                        node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
-                        node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
-                        node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
-                        node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
-                    };
-                    const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
-                    const newLedgerList = setTpMonthToLedger(data.ledgerData, data2.slmList, data2.nextSlmList, data2.endSlmList, data2.yearSlmList, data2.curYearStageData);
-                    baseLedgerTree.loadDatas(newLedgerList);
-                    treeCalc.calculateAll(baseLedgerTree);
-                    const huizongTree = createNewPathTree('filter', huizongTreeSetting);
-                    for (const d of baseLedgerTree.nodes) {
-                        if (!d.b_code) {
-                            const one = _.find(selectedLedgerList, function (item) {
-                                return item === d.ledger_id;
-                            });
-                            if (one) {
-                                huizongTree.addData(d, showList);
-                            }
+                    }
+                    node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
+                    node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
+                    node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
+                    node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
+                };
+                const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
+                const newLedgerList = setTpMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList, data.curYearStageData);
+                baseLedgerTree.loadDatas(newLedgerList);
+                treeCalc.calculateAll(baseLedgerTree);
+                const huizongTree = createNewPathTree('filter', huizongTreeSetting);
+                for (const d of baseLedgerTree.nodes) {
+                    if (!d.b_code) {
+                        const one = _.find(selectedLedgerList, function (item) {
+                            return item === d.ledger_id;
+                        });
+                        if (one) {
+                            huizongTree.addData(d, showList);
                         }
                     }
-                    huizongTree.sortTreeNode(true);
-                    treeCalc.calculateAll(huizongTree);
-                    console.log(huizongTree);
-                    SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
-                }, null, true);
+                }
+                huizongTree.sortTreeNode(true);
+                treeCalc.calculateAll(huizongTree);
+                console.log(huizongTree);
+                SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
             }, null, true);
         },
         dropDownHtml: function (order) {

+ 20 - 1
app/public/js/schedule_stage_tp.js

@@ -73,7 +73,7 @@ $(function () {
     SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
 
     if (curScheduleStage && curScheduleStage.order) {
-        postData('/tender/' + getTenderId() + '/measure/stage/' + curScheduleStage.order + '/load', { filter: 'ledger', comefrom: 'schedule' }, function (data) {
+        postData('/tender/' + getTenderId() + '/schedule/stage/' + curScheduleStage.order + '/load', {}, function (data) {
             const calcList = ['year_gather_tp',
                 'contract_tp', 'qc_qty', 'qc_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'];
@@ -134,6 +134,7 @@ $(function () {
             }
             ledgerTree.sortTreeNode(true);
             treeCalc.calculateAll(ledgerTree);
+            calcGatherTpAndUpdate(ledgerTree.nodes);
             SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
         }, null, true);
     }
@@ -207,6 +208,24 @@ $(function () {
     });
 });
 
+function calcGatherTpAndUpdate(tree) {
+    if (tree.length > 0) {
+        let total_tp = 0;
+        for (const t of tree) {
+            if (t.is_leaf && t.gather_tp) {
+                total_tp = ZhCalc.add(total_tp, t.gather_tp);
+            }
+        }
+        console.log(curScheduleStage.tp, total_tp);
+        if (curScheduleStage.tp !== total_tp) {
+            // 更新计量总金额并更新金额模式总金额
+
+        }
+
+    }
+
+}
+
 function setMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedgerData) {
     if (slm.length > 0) {
         for(const s of slm) {