ソースを参照

本期已用变更问题

MaiXinRong 3 年 前
コミット
98cf2d5146
1 ファイル変更5 行追加12 行削除
  1. 5 12
      app/service/stage_change.js

+ 5 - 12
app/service/stage_change.js

@@ -322,7 +322,7 @@ module.exports = app => {
                     '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON scf.sid = s.id' +
                     '  WHERE scf.tid = ? And scf.cid = ? And s.order < ?';
                 const pre = await this.db.query(preSql, [tid, cid, stage.order]);
-                const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid';
+                const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ?';
                 const curAll = await this.db.query(sql, [stage.id]);
                 const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
                 return [...pre, ...cur];
@@ -360,17 +360,10 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async getStageUsedChangeId(sid) {
-            const sql = 'SELECT c.`cid`, sum(qty) As qty FROM ' + this.tableName + ' As c' +
-                        '  INNER JOIN (' +
-                        '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid` From ' + this.tableName +
-                        '      WHERE sid = ?' +
-                        '      GROUP By `lid`, `pid`, `cbid`' +
-                        '  ) As m' +
-                        '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid' +
-                        '  GROUP BY c.`cid`';
-            const sqlParam = [sid];
-            const result = await this.db.query(sql, sqlParam);
-            return this._.map(this._.filter(result, 'qty'), 'cid');
+            const sql = 'SELECT cid, qty FROM ' + this.tableName + ' WHERE sid = ?';
+            const curAll = await this.db.query(sql, [sid]);
+            const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+            return this._.map(this._.filter(cur, 'qty'), 'cid');
         }
 
         async getFinalStageData(tid, sid) {