Kaynağa Gözat

debug模式下,检查变更统计错误

MaiXinRong 3 hafta önce
ebeveyn
işleme
24b5044f0a

+ 51 - 0
app/controller/stage_controller.js

@@ -590,6 +590,54 @@ module.exports = app => {
             return checkData.checkResult.error;
         }
 
+        async _checkChangeDetail(ctx) {
+            const errors = [];
+            const checkBills = await this.ctx.service.stageChange.getUsedId(ctx.stage.id);
+            const curBillsData = ctx.stage.readOnly
+                ? await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
+                : await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, ctx.stage.id);
+            this.ctx.helper.assignRelaData(checkBills, [
+                { data: curBillsData, fields: ['qc_qty', 'qc_minus_qty'], prefix: '', relaId: 'lid' },
+            ], 'lid');
+            const checkPos = await this.ctx.service.stageChange.getUsedId(ctx.stage.id, false);
+            const curPosData = ctx.stage.readOnly
+                ? await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
+                : await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, ctx.stage.id);
+            this.ctx.helper.assignRelaData(checkPos, [
+                { data: curPosData, fields: ['qc_qty', 'qc_minus_qty'], prefix: '', relaId: 'pid' },
+            ], 'pid');
+            const stageChange = ctx.stage.readOnly
+                ? await ctx.service.stageChange.getAuditorAllStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
+                : await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
+            for (const cb of checkBills) {
+                const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === '-1'});
+                const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
+                let qc_qty = 0, qc_minus_qty = 0;
+                for (const uc of useChanges) {
+                    if (uc.no_value) {
+                        qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
+                    } else {
+                        qc_qty = this.ctx.helper.add(qc_qty, uc.qty);
+                    }
+                }
+                if (qc_qty !== checkQcQty || qc_minus_qty !== checkQcMinusQty) errors.push({ lid: cb.lid });
+            }
+            for (const cb of checkPos) {
+                const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === cb.pid; });
+                const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
+                let qc_qty = 0, qc_minus_qty = 0;
+                for (const uc of useChanges) {
+                    if (uc.no_value) {
+                        qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
+                    } else {
+                        qc_qty = this.ctx.helper.add(qc_qty, uc.qty);
+                    }
+                }
+                if (qc_qty !== checkQcQty || qc_minus_qty !== checkQcMinusQty) errors.push({ lid: cb.lid, pid: cb.pid });
+            }
+            return errors;
+        }
+
         async stageCheck(ctx) {
             try {
                 if (!ctx.query.type) throw '参数错误';
@@ -603,6 +651,9 @@ module.exports = app => {
                         case 'change_over':
                             result.change_over = await this._checkChangeBillsOver(ctx);
                             break;
+                        case 'change_detail':
+                            result.change_detail = ctx.session.sessionUser.loginStatus ? await this._checkChangeDetail(ctx) : [];
+                            break;
                     }
                 }
                 ctx.body = { err: 0, msg: '', data: result };

+ 2 - 1
app/public/js/ledger_check.js

@@ -33,6 +33,7 @@ const ledgerCheckType = {
     },
     minus_cb: { value: 13, text: '负变更清单漏计', url: window.location.pathname + '/stageCheck?type=minus_cb' },
     change_over: { value: 14, text: '变更令超计', url: window.location.pathname + '/stageCheck?type=change_over'},
+    change_detail: { value: 15, text: '变更统计错误', url: window.location.pathname + '/stageCheck?type=change_detail'},
 };
 const ledgerCheckUtil = {
     checkSibling: function (ledgerTree, ledgerPos, decimal, option) {
@@ -525,7 +526,7 @@ const ledgerCheck2 = async function (setting) {
             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, lid: mcb.lid
+                        type: checkInfo.value, code: mcb.memo, b_code: mcb.b_code, name: mcb.name, lid: mcb.lid, pid: mcb.pid,
                     });
                 });
             }

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

@@ -255,6 +255,7 @@ $(document).ready(() => {
         over: { enable: 1, isTz: checkTzMeasureType(), checkInfo: tenderInfo.checkOverInfo },
         limit3f: { enable: 1, checkType: [], status: thirdParty, },
         minus_cb: { enable: hintMinusCb },
+        change_detail: { enable: is_debug },
         // change_over: { enable: 1 },
     };
     if (tender.s2b_gxby_check) checkOption.limit3f.checkType.push('gxby');

+ 5 - 0
app/service/stage_change.js

@@ -955,6 +955,11 @@ module.exports = app => {
                 }, { where: { id: this._.map(oldSBLists, 'id') } });
             }
         }
+
+        async getUsedId(sid, bills = true) {
+            const sql = `SELECT lid, pid FROM ${this.tableName} WHERE sid = ? and pid ${(bills ? '=' : '<>')} ? GROUP BY lid ${(bills ? '' : ', pid')}`;
+            return await this.db.query(sql, [sid, '-1'])
+        }
     }
 
     return StageChange;