|
@@ -86,7 +86,7 @@ module.exports = app => {
|
|
' WHERE tid = ? And sid = ?' +
|
|
' WHERE tid = ? And sid = ?' +
|
|
' GROUP By `lid`, `pid`' +
|
|
' GROUP By `lid`, `pid`' +
|
|
' ) As m ' +
|
|
' ) As m ' +
|
|
- ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid`' +
|
|
|
|
|
|
+ ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid` And c.lid = m.lid And c.pid = m.pid' +
|
|
' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
' ON c.cid = oc.cid';
|
|
' ON c.cid = oc.cid';
|
|
const sqlParam = [tid, sid];
|
|
const sqlParam = [tid, sid];
|
|
@@ -102,7 +102,7 @@ module.exports = app => {
|
|
' WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
|
|
' WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
|
|
' GROUP By `lid`, `pid`' +
|
|
' GROUP By `lid`, `pid`' +
|
|
' ) As m ' +
|
|
' ) As m ' +
|
|
- ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid`' +
|
|
|
|
|
|
+ ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid` And c.lid = m.lid And c.pid = m.pid' +
|
|
' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
' ON c.cid = oc.cid';
|
|
' ON c.cid = oc.cid';
|
|
const sqlParam = [tid, sid, times, times, order];
|
|
const sqlParam = [tid, sid, times, times, order];
|
|
@@ -299,17 +299,18 @@ module.exports = app => {
|
|
' FROM ' + this.ctx.service.changeAuditList.tableName + ' As cb' +
|
|
' FROM ' + this.ctx.service.changeAuditList.tableName + ' As cb' +
|
|
' LEFT JOIN ' + this.tableName + ' As c ON cb.id = c.cbid ' +
|
|
' LEFT JOIN ' + this.tableName + ' As c ON cb.id = c.cbid ' +
|
|
' INNER JOIN (' +
|
|
' INNER JOIN (' +
|
|
- ' SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid`, sChange.`sid`, `cid` ' +
|
|
|
|
|
|
+ ' SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid`, sChange.`sid`, `cid` ' +
|
|
' FROM ' + this.tableName + ' As sChange' +
|
|
' FROM ' + this.tableName + ' As sChange' +
|
|
' LEFT JOIN ' + this.ctx.service.stage.tableName + ' As s ON sChange.sid = s.id' +
|
|
' LEFT JOIN ' + this.ctx.service.stage.tableName + ' As s ON sChange.sid = s.id' +
|
|
' WHERE sChange.tid = ? AND cid = ?' + filter +
|
|
' WHERE sChange.tid = ? AND cid = ?' + filter +
|
|
' GROUP By `lid`, `pid`, `cbid`, sChange.`sid`' +
|
|
' GROUP By `lid`, `pid`, `cbid`, sChange.`sid`' +
|
|
' ) As m' +
|
|
' ) As m' +
|
|
- ' ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.`cbid` = m.`cbid` AND c.`sid` = m.`sid` And c.`cid` = m.`cid`' +
|
|
|
|
|
|
+ ' ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.`cbid` = m.`cbid` AND c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`lid` = m.`lid` And c.`pid` = m.`pid`' +
|
|
' WHERE cb.cid = ?' +
|
|
' WHERE cb.cid = ?' +
|
|
' GROUP By c.`cbid`';
|
|
' GROUP By c.`cbid`';
|
|
const sqlParam = [tid, cid, cid];
|
|
const sqlParam = [tid, cid, cid];
|
|
|
|
|
|
|
|
+ console.log(this.db.format(sql, sqlParam));
|
|
return await this.db.query(sql, sqlParam);
|
|
return await this.db.query(sql, sqlParam);
|
|
}
|
|
}
|
|
|
|
|