Pārlūkot izejas kodu

修复新增部位树结构混乱问题

laiguoran 3 gadi atpakaļ
vecāks
revīzija
98576b6094
1 mainītis faili ar 22 papildinājumiem un 22 dzēšanām
  1. 22 22
      app/service/change_ledger.js

+ 22 - 22
app/service/change_ledger.js

@@ -138,23 +138,23 @@ module.exports = app => {
          * @private
          */
         async _getMaxLid(mid) {
-            const cacheKey = this.setting.keyPre + mid;
-            let maxId = parseInt(await this.cache.get(cacheKey));
-            if (!maxId) {
-                const sql = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
-                const sqlParam = [this.setting.kid, this.ctx.service.ledger.tableName, mid];
-                const queryResult = await this.db.queryOne(sql, sqlParam);
-                maxId = queryResult.max_id || 0;
-                if (this.newBills) {
-                    const sql2 = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
-                    const sqlParam2 = [this.setting.kid, this.tableName, mid];
-                    const queryResult2 = await this.db.queryOne(sql2, sqlParam2);
-                    if (maxId < queryResult2.max_id || 0) {
-                        maxId = queryResult2.max_id || 0;
-                    }
+            // const cacheKey = this.setting.keyPre + mid;
+            // let maxId = parseInt(await this.cache.get(cacheKey));
+            // if (!maxId) {
+            const sql = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
+            const sqlParam = [this.setting.kid, this.ctx.service.ledger.tableName, mid];
+            const queryResult = await this.db.queryOne(sql, sqlParam);
+            let maxId = queryResult.max_id || 0;
+            if (this.newBills) {
+                const sql2 = 'SELECT Max(??) As max_id FROM ?? Where ' + this.setting.mid + ' = ?';
+                const sqlParam2 = [this.setting.kid, this.tableName, mid];
+                const queryResult2 = await this.db.queryOne(sql2, sqlParam2);
+                if (maxId < queryResult2.max_id || 0) {
+                    maxId = queryResult2.max_id || 0;
                 }
-                this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
             }
+            //     this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
+            // }
             return maxId;
         }
 
@@ -287,7 +287,7 @@ module.exports = app => {
             data[this.setting.isLeaf] = true;
             const result = await this.transaction.insert(this.tableName, data);
 
-            this._cacheMaxLid(mid, maxId + 1);
+            // this._cacheMaxLid(mid, maxId + 1);
 
             return result;
         }
@@ -364,7 +364,7 @@ module.exports = app => {
                     newDatas.push(newData);
                 }
                 const insertResult = await this.transaction.insert(this.tableName, newDatas);
-                this._cacheMaxLid(mid, maxId + count);
+                // this._cacheMaxLid(mid, maxId + count);
 
                 if (insertResult.affectedRows !== count) throw '新增节点数据错误';
                 await this.transaction.commit();
@@ -725,7 +725,7 @@ module.exports = app => {
                         await this.calcNode(qd, this.transaction);
                     }
                 }
-                this._cacheMaxLid(tenderId, maxId + data.length);
+                // this._cacheMaxLid(tenderId, maxId + data.length);
                 await this.transaction.commit();
             } catch (err) {
                 await this.transaction.rollback();
@@ -794,7 +794,7 @@ module.exports = app => {
                         await this.calcNode(qd, this.transaction);
                     }
                 }
-                this._cacheMaxLid(tenderId, maxId + data.length);
+                // this._cacheMaxLid(tenderId, maxId + data.length);
                 await this.transaction.commit();
             } catch (err) {
                 await this.transaction.rollback();
@@ -1277,7 +1277,7 @@ module.exports = app => {
                 if (pasteBillsData.length > 0) {
                     const newData = await this.transaction.insert(this.tableName, pasteBillsData);
                 }
-                this._cacheMaxLid(tid, maxId);
+                // this._cacheMaxLid(tid, maxId);
                 if (pastePosData.length > 0) {
                     await this.transaction.insert(this.ctx.service.changePos.tableName, pastePosData);
                 }
@@ -1367,7 +1367,7 @@ module.exports = app => {
                 throw err;
             }
 
-            this._cacheMaxLid(tenderId, maxId + 1);
+            // this._cacheMaxLid(tenderId, maxId + 1);
 
             // 查询应返回的结果
             const resultData = {};
@@ -1555,7 +1555,7 @@ module.exports = app => {
             if (changeId) data.ccid = changeId;
             const result = await this.transaction.insert(this.tableName, data);
 
-            this._cacheMaxLid(tenderId, maxId + 1);
+            // this._cacheMaxLid(tenderId, maxId + 1);
 
             return [result, data];
         }