浏览代码

上报检查,调整

MaiXinRong 1 年之前
父节点
当前提交
60daab00b9

+ 23 - 0
app/controller/stage_controller.js

@@ -399,6 +399,16 @@ module.exports = app => {
             }
         }
 
+        async _innerCheckChangeBillsOver(ctx, checkData) {
+            const change = await this.ctx.service.change.getAllDataByCondition({ where: { tid: ctx.tender.id }});
+            if (change.length > 0) {
+                const cid = change.map(x => { return x.cid; });
+                const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid } });
+                const endStageChange = await this.ctx.service.stageChange.getFinalUsedData(ctx.tender.id, cid);
+                checkData.checkChangeBillsOver(change, changeBills, endStageChange, ctx.stage.id);
+            }
+        }
+
         async check(ctx) {
             try {
                 const helper = this.ctx.helper;
@@ -437,6 +447,9 @@ module.exports = app => {
                     }
                 }
                 if (ctx.stage.readySettle) checkData.checkSettle();
+                if (ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) {
+                    await this._innerCheckChangeBillsOver(ctx, checkData);
+                }
                 ctx.body = { err: 0, msg: '', data: checkData.checkResult };
             } catch (err) {
                 this.log(err);
@@ -457,6 +470,13 @@ module.exports = app => {
             return checkData.checkResult.error;
         }
 
+        async _checkChangeBillsOver(ctx) {
+            const checkDataModel = require('../lib/ledger').checkData;
+            const checkData = new checkDataModel(ctx, measureType);
+            await this._innerCheckChangeBillsOver(ctx, checkData);
+            return checkData.checkResult.error;
+        }
+
         async stageCheck(ctx) {
             try {
                 if (!ctx.query.type) throw '参数错误';
@@ -467,6 +487,9 @@ module.exports = app => {
                         case 'minus_cb':
                             result.minus_cb = await this._checkMinusChangeBills(ctx);
                             break;
+                        case 'change_over':
+                            result.change_over = await this._checkChangeBillsOver(ctx);
+                            break;
                     }
                 }
                 ctx.body = { err: 0, msg: '', data: result };

+ 40 - 0
app/lib/ledger.js

@@ -1079,6 +1079,46 @@ class checkData {
             });
         });
     }
+    checkChangeBillsOver(change, changeBills, finalStageChange, curStageId) {
+        const error = this.checkResult.error;
+        const helper = this.ctx.helper;
+        const changeIndex = {};
+        change.forEach(c => {
+            changeIndex[c.cid] = c;
+            c.bills = [];
+            c.billsIndex = {};
+            c.stageChange = [];
+        });
+        changeBills.forEach(cb => {
+            const c = changeIndex[cb.cid];
+            if (c) c.bills.push(cb);
+            c.billsIndex[cb.id] = cb;
+            cb.used_qty = 0;
+            cb.qty = parseFloat(cb.samount);
+        });
+        finalStageChange.forEach(sc => {
+            if (!sc.qty) return;
+            const c = changeIndex[sc.cid];
+            if (c) {
+                c.used = true;
+                const cb = c.billsIndex[sc.cbid];
+                if (cb) {
+                    cb.used_qty = helper.add(cb.used_qty, sc.qty);
+                    if (sc.sid === curStageId) {
+                        cb.cur_used = true;
+                        cb.lid = sc.lid;
+                    }
+                }
+            }
+        });
+        change.forEach(c => {
+            if (!c.used) return;
+            c.bills.forEach(b => {
+                if (!b.cur_used) return;
+                if (b.used_qty > b.qty) error.push({ b_code: b.code, name: b.name, errorType: 'change_over', memo: c.code, lid: b.lid });
+            });
+        });
+    }
 
     checkSettle() {
         const settleStatus = this.ctx.service.settle.settleStatus;

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

@@ -28,6 +28,7 @@ const ledgerCheckType = {
         ]
     },
     minus_cb: { value: 12, text: '负变更清单漏计', url: window.location.pathname + '/stageCheck?type=minus_cb' },
+    change_over: { value: 13, text: '变更令超计', url: window.location.pathname + '/stageCheck?type=change_over'},
 };
 const ledgerCheckUtil = {
     checkSibling: function (ledgerTree, ledgerPos, decimal, option) {
@@ -344,14 +345,14 @@ const ledgerCheck2 = async function (setting) {
             }
         } else if (checkInfo.url) {
             const errors = await postDataAsync(checkInfo.url, {}, false);
-            if (errors && errors.minus_cb) {
-                errors.minus_cb.forEach(mcb => {
+            if (errors && errors[prop]) {
+                errors[prop].forEach(mcb => {
                     checkData.warning_data.push({
-                        type: checkInfo.value, code: mcb.memo, b_code: mcb.b_code, name: mcb.name,
+                        type: checkInfo.value, code: mcb.memo, b_code: mcb.b_code, name: mcb.name, lid: mcb.lid
                     });
                 });
             }
-            progressData.push({key: prop, caption: checkInfo.text, error: errors && errors.minus_cb ? errors.minus_cb.length : 0});
+            progressData.push({key: prop, caption: checkInfo.text, error: errors && errors[prop] ? errors[prop].length : 0});
         } else {
             const errors = ledgerCheckUtil[checkInfo.fun](ledger, ledgerPos, decimal, checkOption[prop]) || [];
             assignWarningData(errors, checkInfo.value, checkData.warning_data);

+ 19 - 2
app/public/js/shares/cs_tools.js

@@ -84,6 +84,7 @@ const showSelectTab = function(select, spread, afterShow) {
                                 case 's2b_lost_gxby': return '遗漏计量(工序报验)';
                                 case 's2b_lost_dagl': return '遗漏计量(档案管理)';
                                 case 'minus_cb': return '负变更清单漏计';
+                                case 'change_over': return '变更令超计';
                                 case 'settle': return '结算清单';
                                 default: return '';
                             }
@@ -146,7 +147,15 @@ const showSelectTab = function(select, spread, afterShow) {
                 if (!sourceTree) return;
 
                 for (const d of data) {
-                    d.serialNo = sourceTree.getNodeIndex(sourceTree.getItems(d.ledger_id)) + 1;
+                    if (d.ledger_id) {
+                        d.serialNo = sourceTree.getNodeIndex(sourceTree.getItems(d.ledger_id)) + 1;
+                    } else if (d.lid) {
+                        const nodeIndex = sourceTree.nodes.findIndex(x => { return x.id === d.lid });
+                        if (nodeIndex >= 0) {
+                            d.serialNo = nodeIndex + 1;
+                            d.ledger_id = sourceTree.nodes[nodeIndex].ledger_id;
+                        }
+                    }
                 }
                 data.sort(function (a, b) {
                     return a.serialNo ? (b.serialNo ? a.serialNo - b.serialNo : 1) : 1;
@@ -327,7 +336,15 @@ const showSelectTab = function(select, spread, afterShow) {
                 if (!sourceTree) return;
 
                 for (const d of data.warning_data) {
-                    d.serialNo = sourceTree.getNodeIndex(sourceTree.getItems(d.ledger_id)) + 1;
+                    if (d.ledger_id) {
+                        d.serialNo = sourceTree.getNodeIndex(sourceTree.getItems(d.ledger_id)) + 1;
+                    } else if (d.lid) {
+                        const nodeIndex = sourceTree.nodes.findIndex(x => { return x.id === d.lid });
+                        if (nodeIndex >= 0) {
+                            d.serialNo = nodeIndex + 1;
+                            d.ledger_id = sourceTree.nodes[nodeIndex].ledger_id;
+                        }
+                    }
                 }
 
                 $('#' + setting.id + '-time').html('检查时间:' + moment(data.check_time).format('YYYY-MM-DD HH:mm:ss'));

+ 1 - 1
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -2413,7 +2413,7 @@ const SpreadJsObj = {
          */
         getUnitCellType: function (comboEdit, items = ['m', 'km', 'm2', 'm3', 'dm3', 'kg', 't', 'm3·km',
             '总额', '月' ,'项', '处' ,'个', '根', '棵', '块', '台', '系统', '延米', '每一试桩',
-            '桥长米', '公路公里', '株', '组', '座', '元', '工日', '套', '台班', '艘班', '亩', '片',
+            '桥长米', '公路公里', '株', '组', '座', '元', '工日', '套', '台班', '辆', '艘班', '亩', '片',
             'm/处', 'm/道', 'm/座', 'm2/m', 'm3/m', 'm3/处', '根/米', 'm3/m2']) {
             let combo = this.getActiveComboCellType();
             combo.editable(comboEdit);

+ 27 - 0
app/service/stage.js

@@ -305,6 +305,33 @@ module.exports = app => {
         }
 
         /**
+         * 获取 最新一期 期计量
+         * @param tenderId
+         * @param includeUnCheck
+         * @return {Promise<*>}
+         */
+        async getFlowLatestStage(tenderId, includeUnCheck = false) {
+            const stages = await this.getAllDataByCondition({ where: {tid: tenderId}, orders: [['order', 'desc']] });
+            const flowStages = [];
+            for (const s of stages) {
+                if (s.status !== auditConst.stage.status.checked) flowStages.push(s);
+            }
+            let stage;
+            if (flowStages.length === 0) {
+                stage = stages[0];
+            } else {
+                const firstFlowStage = flowStages[flowStages.length - 1];
+                if (includeUnCheck) {
+                    stage = firstFlowStage.status === auditConst.stage.status.uncheck ? firstFlowStage : stages[flowStages.length];
+                } else {
+                    stage = firstFlowStage.status === auditConst.stage.status.uncheck ? stages[flowStages.length] : firstFlowStage;
+                }
+            }
+            if (stage) stage.tp_history = stage.tp_history ? JSON.parse(stage.tp_history) : [];
+            return stage;
+        }
+
+        /**
          * 获取 最新一期 审批完成的 期计量
          * @param tenderId
          * @return {Promise<*>}

+ 3 - 3
app/service/tender_cache.js

@@ -57,7 +57,7 @@ module.exports = app => {
                 tender.pre_flow = cache.stage_flow_pre_info ? JSON.parse(cache.stage_flow_pre_info) : null;
                 tender.stage_tp = JSON.parse(cache.stage_flow_cur_tp || cache.stage_flow_pre_tp);
                 tender.progress = {
-                    title: `第${cache.stage_count}期`,
+                    title: `第${tender.cur_flow.order}期`,
                     status: auditConst.stage.tiStatusString[cache.stage_status],
                     status_class: auditConst.stage.tiStatusStringClass[cache.stage_status],
                 };
@@ -70,7 +70,7 @@ module.exports = app => {
                 tender.pre_flow = cache.stage_flow_pre_info ? JSON.parse(cache.stage_flow_pre_info) : null;
                 tender.stage_tp = cache.stage_flow_pre_tp ? JSON.parse(cache.stage_flow_pre_tp) : {};
                 tender.progress = {
-                    title: `第${cache.stage_complete_count}期`,
+                    title: `第${tender.pre_flow.order}期`,
                     status: auditConst.stage.tiStatusString[auditConst.stage.status.checked],
                     status_class: auditConst.stage.tiStatusStringClass[auditConst.stage.status.checked],
                 };
@@ -390,7 +390,7 @@ module.exports = app => {
 
         async _refreshStageRela(tender, data) {
             if (tender.ledger_status === auditConst.ledger.status.checked) {
-                const lastStage = await this.ctx.service.stage.getLastestStage(tender.id, true);
+                const lastStage = await this.ctx.service.stage.getFlowLatestStage(tender.id, true);
                 if (!lastStage) return;
 
                 data.stage_count = lastStage.order;